INFO 623 Social Network Analytics

Project : Social Network Analytics on Facebook Users

Team:

1. Karthikreddy Kuna (KK3375)

2. Pradeep Kankipati(PK593)

In [103]:
## Imports all necessary modules
import networkx as nx
import matplotlib.pyplot as plt
import warnings
warnings.filterwarnings('ignore')
from networkx import community
from networkx.algorithms.community import greedy_modularity_communities
import random
import math
import csv
from sklearn import svm
from sklearn.metrics import accuracy_score , f1_score
from sklearn.preprocessing import normalize
import numpy as np
from sklearn.linear_model import LogisticRegression
from sklearn.preprocessing import StandardScaler 
Generate the Facebook social network.
In [2]:
G_fbsocial = nx.read_edgelist("facebook_combined.txt", create_using = nx.Graph(), nodetype=int)
In [3]:
print(nx.info(G_fbsocial))
Name: 
Type: Graph
Number of nodes: 4039
Number of edges: 88234
Average degree:  43.6910
In [4]:
print("Number of Actors:", nx.number_of_nodes(G_fbsocial),'\n')
print("Number of Ties:", nx.number_of_edges(G_fbsocial),'\n')
print("Diameter:", nx.diameter(G_fbsocial),'\n')
print("Average Clustering:", nx.average_clustering(G_fbsocial),'\n')
print("Network Density:", nx.density(G_fbsocial), '\n')
print("Connected Graph:", nx.is_connected(G_fbsocial))
Number of Actors: 4039 

Number of Ties: 88234 

Diameter: 8 

Average Clustering: 0.6055467186200876 

Network Density: 0.010819963503439287 

Connected Graph: True
In [5]:
def plt_network(G):
    pos = nx.spring_layout(G)
    plt.style.use('fivethirtyeight')
    plt.rcParams['figure.figsize'] = (30, 25)
    plt.axis('off')
    nx.draw_networkx(G, pos, with_labels = False, node_size = 30, node_color='r')
    plt.show()
In [6]:
plt_network(G_fbsocial)

Let's create a subgraph with minimum degree 50.

In [7]:
node_degree_dict=nx.degree(G_fbsocial)
G_temp=nx.subgraph(G_fbsocial,[x for x in G_fbsocial.nodes() if node_degree_dict[x]>50])
G_subgraph_fb = nx.Graph(G_temp)
G_subgraph_fb.remove_nodes_from(list(nx.isolates(G_subgraph_fb)))
In [8]:
print(nx.info(G_subgraph_fb))
Name: 
Type: Graph
Number of nodes: 1143
Number of edges: 50324
Average degree:  88.0560
In [9]:
plt_network(G_subgraph_fb)
In [10]:
###Define function to plot the centrality
def plt_network_centrality(G, central_measure, central_list):
    labels = {} 
    for node in G.nodes():
        if node in central_list:
            labels[node] = node
    pos = nx.spring_layout(G)
    node_color = [20000.0 * G.degree(v) for v in G]
    node_size =  [v * 10000 for v in central_measure.values()]
    plt.style.use('fivethirtyeight')
    plt.rcParams['figure.figsize'] = (30, 25)
    nx.draw_networkx(G, pos=pos, with_labels=False,
                     node_color=node_color,
                     node_size=node_size )
    nx.draw_networkx_labels(G,pos,labels,font_size=35,font_color='r')
    plt.axis('off')

Centrality

Lets find the actor(s) with the highest degree centrality

The degree of a actor is defined as number of connecting ties particular actor has with others. To calculate Degree centrality of a actor, the degree of a actor is divided by number of other actors in the network(n-1).

Degree centrality metric defines importance of a actor in a network as being measured based on its degree i.e the higher the degree of a actor, the more important it is in a network.

G_fbsocial_degree centrality
In [11]:
degree_central = nx.degree_centrality(G_fbsocial)
top_degree_central = sorted(degree_central, key=degree_central.get, reverse=True)[:5]
print("Top 5 degree centrality nodes:", top_degree_central)
Top 5 degree centrality nodes: [107, 1684, 1912, 3437, 0]
In [12]:
plt_network_centrality(G_fbsocial,degree_central, top_degree_central)
In [13]:
G_fbsocial.degree(107)
Out[13]:
1045
In [14]:
G_fbsocial.degree(1684)
Out[14]:
792
In [15]:
G_fbsocial.degree(1912)
Out[15]:
755
In [16]:
G_fbsocial.degree(3437)
Out[16]:
547
In [17]:
G_fbsocial.degree(0)
Out[17]:
347
G_subgraph_fb_degree centrality
In [18]:
degree_central_sub = nx.degree_centrality(G_subgraph_fb)
top_degree_central_sub = sorted(degree_central_sub, key=degree_central_sub.get, reverse=True)[:5]
print("Top 5 degree centrality nodes:", top_degree_central_sub)
Top 5 degree centrality nodes: [107, 1912, 2347, 2543, 1684]
In [19]:
plt_network_centrality(G_subgraph_fb,degree_central_sub, top_degree_central_sub)

Lets find the actor(s) with the highest closeness centrality

Closeness centrality metric defines the importance of a actor in a network as being measured by how close it is to all other actors in the network.For a actor, it is defined as the average of the geodesic distance between that actor to all other actors in the network.

G_fbsocial Closeness centrality
In [20]:
close_central = nx.closeness_centrality(G_fbsocial)
top_close_central = sorted(close_central, key=close_central.get, reverse=True)[:5]
print("Top 5 closeness centrality nodes:", top_close_central)
Top 5 closeness centrality nodes: [107, 58, 428, 563, 1684]
In [21]:
closeness_centrality = sorted(close_central.items(), key = lambda i:(i[1], i[0]), reverse = True)[:5]
closeness_centrality
Out[21]:
[(107, 0.45969945355191255),
 (58, 0.3974018305284913),
 (428, 0.3948371956585509),
 (563, 0.3939127889961955),
 (1684, 0.39360561458231796)]
In [22]:
plt_network_centrality(G_fbsocial,close_central, top_close_central)
In [23]:
short_path = nx.single_source_shortest_path_length(G_fbsocial, source = 107)
k = sum(short_path.values())
print("Sum of geodesic distance from '107' is:",k)
Sum of geodesic distance from '107' is: 8784
In [24]:
short_path = nx.single_source_shortest_path_length(G_fbsocial, source = 58)
k = sum(short_path.values())
print("Sum of geodesic distance from '58' is:",k)
Sum of geodesic distance from '58' is: 10161
In [25]:
short_path = nx.single_source_shortest_path_length(G_fbsocial, source = 428)
k = sum(short_path.values())
print("Sum of geodesic distance from '428' is:",k)
Sum of geodesic distance from '428' is: 10227
In [26]:
short_path = nx.single_source_shortest_path_length(G_fbsocial, source = 563)
k = sum(short_path.values())
print("Sum of geodesic distance from '563' is:",k)
Sum of geodesic distance from '563' is: 10251
In [27]:
short_path = nx.single_source_shortest_path_length(G_fbsocial, source = 1684)
k = sum(short_path.values())
print("Sum of geodesic distance from '1684' is:",k)
Sum of geodesic distance from '1684' is: 10259
G_subgraph_fb Closeness centrality
In [28]:
close_central_sub = nx.closeness_centrality(G_subgraph_fb)
top_close_central_sub = sorted(close_central_sub, key=close_central_sub.get, reverse=True)[:5]
print("Top 5 closeness centrality nodes:", top_close_central_sub)
Top 5 closeness centrality nodes: [107, 1577, 1718, 428, 1465]
In [119]:
closeness_centrality_sub = sorted(close_central_sub.items(), key = lambda i:(i[1], i[0]), reverse = True)[:5]
closeness_centrality_sub
Out[119]:
[(107, 0.5282146160962072),
 (1577, 0.45716573258606885),
 (1718, 0.45425616547334924),
 (428, 0.4519192718638702),
 (1465, 0.4476675813406507)]
In [29]:
plt_network_centrality(G_subgraph_fb,close_central_sub, top_close_central_sub)
Lets find the actor(s) with the highest betweeness centrality

Betweeness centrality metric defines and measures the importance of a actor in a network based upon how many times it occurs in the shortest path between all pair of actors in the network. The actor with highest betweenness centrality acts like a bridge between two social groups.

G_fbsocial Betweeness centrality
In [30]:
between_central = nx.betweenness_centrality(G_fbsocial, normalized=True, endpoints=True)
top_between_central = sorted(between_central, key=between_central.get, reverse=True)[:5]
print("Top 5 betweeness centrality nodes:", top_between_central)
Top 5 betweeness centrality nodes: [107, 1684, 3437, 1912, 1085]
In [31]:
betweenness_centrality = sorted(between_central.items(), key = lambda i:(i[1], i[0]), reverse = True)[:5]
betweenness_centrality
Out[31]:
[(107, 0.48077531149557645),
 (1684, 0.33812535393929544),
 (3437, 0.23649361170042005),
 (1912, 0.22967697101070242),
 (1085, 0.14943647607698152)]
In [32]:
plt_network_centrality(G_fbsocial,between_central, top_between_central )
G_subgraph_fb Betweeness centrality
In [33]:
between_central_sub = nx.betweenness_centrality(G_subgraph_fb, normalized=True, endpoints=True)
top_between_central_sub = sorted(between_central_sub, key=between_central_sub.get, reverse=True)[:5]
print("Top 5 betweeness centrality nodes:", top_between_central_sub)
Top 5 betweeness centrality nodes: [107, 1684, 1912, 1718, 1577]
In [118]:
betweenness_centrality_sub = sorted(between_central_sub.items(), key = lambda i:(i[1], i[0]), reverse = True)[:5]
betweenness_centrality_sub
Out[118]:
[(107, 0.5530400036447516),
 (1684, 0.346713961884091),
 (1912, 0.1867928883663688),
 (1718, 0.13945898618781966),
 (1577, 0.12701324126479357)]
In [34]:
plt_network_centrality(G_subgraph_fb,between_central_sub, top_between_central_sub)
Lets find the actor(s) with the highest eigenvector centrality

Eigenvector centrality is a measure of the influence of a actor in a network. It assigns relative scores to all actors in the network based on the concept that connections to high-scoring actors contribute more to the score of the actor in question than equal connections to low-scoring actors.

G_fbsocial Eigenvector centrality
In [35]:
eigen_central = nx.eigenvector_centrality(G_fbsocial)
top_eigen_central = sorted(eigen_central, key=eigen_central.get, reverse=True)[:5]
print("Top 5 eigenvector centrality nodes:", top_eigen_central)
Top 5 eigenvector centrality nodes: [1912, 2266, 2206, 2233, 2464]
In [36]:
eigen_centrality = sorted(eigen_central.items(), key = lambda i:(i[1], i[0]), reverse = True)[:5]
eigen_centrality
Out[36]:
[(1912, 0.09540696149067629),
 (2266, 0.08698327767886553),
 (2206, 0.08605239270584343),
 (2233, 0.08517340912756598),
 (2464, 0.08427877475676092)]
In [37]:
plt_network_centrality(G_fbsocial,eigen_central, top_eigen_central)
G_subgraph_fb Eigenvector centrality
In [38]:
eigen_central_sub = nx.eigenvector_centrality(G_subgraph_fb)
top_eigen_central_sub = sorted(eigen_central_sub, key=eigen_central_sub.get, reverse=True)[:5]
print("Top 5 eigenvector centrality nodes:", top_eigen_central_sub)
Top 5 eigenvector centrality nodes: [1912, 2266, 2206, 2233, 2464]
In [120]:
eigen_centrality_sub = sorted(eigen_central_sub.items(), key = lambda i:(i[1], i[0]), reverse = True)[:5]
eigen_centrality_sub
Out[120]:
[(1912, 0.09209797568781998),
 (2266, 0.08634034441692785),
 (2206, 0.08624255422568931),
 (2233, 0.08518486431929224),
 (2464, 0.08461774213989234)]
In [39]:
plt_network_centrality(G_subgraph_fb,eigen_central_sub, top_eigen_central_sub)

Community Detection

Let's create function to generate subgraph based on user and funtion to plot the graph
In [40]:
def create_subgraph(G, user):
    first_degree_connected_nodes = list(G.neighbors(user))
    second_degree_connected_nodes = []
    for x in first_degree_connected_nodes:
        second_degree_connected_nodes+=list(G.neighbors(x))
    second_degree_connected_nodes.remove(user)
    second_degree_connected_nodes = list(set(second_degree_connected_nodes))

    subgraph_user = nx.subgraph(G,first_degree_connected_nodes+second_degree_connected_nodes,)
    return subgraph_user
In [41]:
def plot_subgraph(G, node):
    pos = nx.spring_layout(G)
    node_color = ['yellow' if v == node else 'red' for v in G]
    node_size =  [1000 if v == node else 35 for v in G]
    plt.style.use('fivethirtyeight')
    plt.rcParams['figure.figsize'] = (30, 25)
    plt.axis('off')

    nx.draw_networkx(G, pos, with_labels = False, node_color=node_color,node_size=node_size )
    plt.show()
Girvan newman Algorithm
In [42]:
def edge_to_remove(G):
  G_edge_dict = nx.edge_betweenness_centrality(G)
  edge = ()

  # extract the edge with highest edge betweenness centrality score
  for key, value in sorted(G_edge_dict.items(), key=lambda item: item[1], reverse = True):
      edge = key
      break

  return edge
In [43]:
def girvan_newman(G, comm_num):
    # find number of connected components
    connect = nx.connected_components(G)
    connect_count = nx.number_connected_components(G)
   
    while(connect_count <= (comm_num - 1)):
        G.remove_edge(edge_to_remove(G)[0], edge_to_remove(G)[1])
        connect = nx.connected_components(G)
        connect_count = nx.number_connected_components(G)
        if nx.number_of_edges(G) < 100:
            connect_count = comm_num
    return connect , G
In [44]:
def community_node(G, comm_num = 2):
    # find communities in the graph
    modularity = []
    node_groups = []
    communities ,graph = girvan_newman(G.copy(), comm_num)
    original_graph = G.copy()
    m = original_graph.number_of_edges()
    q = 0 
    for group in communities:
        node_groups.append(list(group))
        for nodei in group:
            for nodej in group:
                ki = original_graph.degree(nodei)
                kj = original_graph.degree(nodej)
                aij = 0
                if graph.has_edge(nodei, nodej) is True:
                    aij = 1
                else:
                    aij = 0
                q = aij - (ki*kj)/(m*2) +q
        q = q/(2*m)
        modularity.append(q)

    return graph , modularity, node_groups
In [45]:
def plot_community_subgraph(G, node_groups):   
    # plot the communities
    colors = ["green", "red", "orange", "blue", "violet", "cyan", "yellow", "indigo", "pink",  "black", "aliceblue", "aqua", "aquamarine", "darkturquoise", "royalblue"]
    plt.style.use('fivethirtyeight')
    plt.rcParams['figure.figsize'] = (30, 25)
    pos = nx.spring_layout(G)
    for i in range(len(node_groups)):
        graph = node_groups[i]
        node_list = [node for node in graph]
        nx.draw(G,  pos,with_labels = False, nodelist=node_list, node_color=colors[i%10], alpha = 0.8)
    plt.show()

Community detection on G_fbsocial

G_fbsocial Girvan newman
In [75]:
graph_fb, modularity_fb, community_node_groups_fb = community_node(G_fbsocial, 2)
In [87]:
modularity_fb
Out[87]:
[0.02175211307680976, 0.021967572832132853]
In [88]:
print("Modularity:", nx.algorithms.community.modularity(G_fbsocial, community_node_groups_fb))
Modularity: 0.04393489913676287
In [122]:
print(community_node_groups_fb)
[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 857, 862, 865, 868, 896, 897, 898, 899, 900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124, 1125, 1126, 1127, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1138, 1139, 1140, 1141, 1142, 1143, 1144, 1145, 1146, 1147, 1148, 1149, 1150, 1151, 1152, 1153, 1154, 1155, 1156, 1157, 1158, 1159, 1160, 1161, 1162, 1163, 1164, 1165, 1166, 1167, 1168, 1169, 1170, 1171, 1172, 1173, 1174, 1175, 1176, 1177, 1178, 1179, 1180, 1181, 1182, 1183, 1184, 1185, 1186, 1187, 1188, 1189, 1190, 1191, 1192, 1193, 1194, 1195, 1196, 1197, 1198, 1199, 1200, 1201, 1202, 1203, 1204, 1205, 1206, 1207, 1208, 1209, 1210, 1211, 1212, 1213, 1214, 1215, 1216, 1217, 1218, 1219, 1220, 1221, 1222, 1223, 1224, 1225, 1226, 1227, 1228, 1229, 1230, 1231, 1232, 1233, 1234, 1235, 1236, 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244, 1245, 1246, 1247, 1248, 1249, 1250, 1251, 1252, 1253, 1254, 1255, 1256, 1257, 1258, 1259, 1260, 1261, 1262, 1263, 1264, 1265, 1266, 1267, 1268, 1269, 1270, 1271, 1272, 1273, 1274, 1275, 1276, 1277, 1278, 1279, 1280, 1281, 1282, 1283, 1284, 1285, 1286, 1287, 1288, 1289, 1290, 1291, 1292, 1293, 1294, 1295, 1296, 1297, 1298, 1299, 1300, 1301, 1302, 1303, 1304, 1305, 1306, 1307, 1308, 1309, 1310, 1311, 1312, 1313, 1314, 1315, 1316, 1317, 1318, 1319, 1320, 1321, 1322, 1323, 1324, 1325, 1326, 1327, 1328, 1329, 1330, 1331, 1332, 1333, 1334, 1335, 1336, 1337, 1338, 1339, 1340, 1341, 1342, 1343, 1344, 1345, 1346, 1347, 1348, 1349, 1350, 1351, 1352, 1353, 1354, 1355, 1356, 1357, 1358, 1359, 1360, 1361, 1362, 1363, 1364, 1365, 1366, 1367, 1368, 1369, 1370, 1371, 1372, 1373, 1374, 1375, 1376, 1377, 1378, 1379, 1380, 1381, 1382, 1383, 1384, 1385, 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399, 1400, 1401, 1402, 1403, 1404, 1405, 1406, 1407, 1408, 1409, 1410, 1411, 1412, 1413, 1414, 1415, 1416, 1417, 1418, 1419, 1420, 1421, 1422, 1423, 1424, 1425, 1426, 1427, 1428, 1429, 1430, 1431, 1432, 1433, 1434, 1435, 1436, 1437, 1438, 1439, 1440, 1441, 1442, 1443, 1444, 1445, 1446, 1447, 1448, 1449, 1450, 1451, 1452, 1453, 1454, 1455, 1456, 1457, 1458, 1459, 1460, 1461, 1462, 1463, 1464, 1465, 1466, 1467, 1468, 1469, 1470, 1471, 1472, 1473, 1474, 1475, 1476, 1477, 1478, 1479, 1480, 1481, 1482, 1483, 1484, 1485, 1486, 1487, 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496, 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, 1515, 1516, 1517, 1518, 1519, 1520, 1521, 1522, 1523, 1524, 1525, 1526, 1527, 1528, 1529, 1530, 1531, 1532, 1533, 1534, 1535, 1536, 1537, 1538, 1539, 1540, 1541, 1542, 1543, 1544, 1545, 1546, 1547, 1548, 1549, 1550, 1551, 1552, 1553, 1554, 1555, 1556, 1557, 1558, 1559, 1560, 1561, 1562, 1563, 1564, 1565, 1566, 1567, 1568, 1569, 1570, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1578, 1579, 1580, 1581, 1582, 1583, 1584, 1585, 1586, 1587, 1588, 1589, 1590, 1591, 1592, 1593, 1594, 1595, 1596, 1597, 1598, 1599, 1600, 1601, 1602, 1603, 1604, 1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613, 1614, 1615, 1616, 1617, 1618, 1619, 1620, 1621, 1622, 1623, 1624, 1625, 1626, 1627, 1628, 1629, 1630, 1631, 1632, 1633, 1634, 1635, 1636, 1637, 1638, 1639, 1640, 1641, 1642, 1643, 1644, 1645, 1646, 1647, 1648, 1649, 1650, 1651, 1652, 1653, 1654, 1655, 1656, 1657, 1658, 1659, 1660, 1661, 1662, 1663, 1664, 1665, 1666, 1667, 1668, 1669, 1670, 1671, 1672, 1673, 1674, 1675, 1676, 1677, 1678, 1679, 1680, 1681, 1682, 1683, 1684, 1685, 1686, 1687, 1688, 1689, 1690, 1691, 1692, 1693, 1694, 1695, 1696, 1697, 1698, 1699, 1700, 1701, 1702, 1703, 1704, 1705, 1706, 1707, 1708, 1709, 1710, 1711, 1712, 1713, 1714, 1715, 1716, 1717, 1718, 1719, 1720, 1721, 1722, 1723, 1724, 1725, 1726, 1727, 1728, 1729, 1730, 1731, 1732, 1733, 1734, 1735, 1736, 1737, 1738, 1739, 1740, 1741, 1742, 1743, 1744, 1745, 1746, 1747, 1748, 1749, 1750, 1751, 1752, 1753, 1754, 1755, 1756, 1757, 1758, 1759, 1760, 1761, 1762, 1763, 1764, 1765, 1766, 1767, 1768, 1769, 1770, 1771, 1772, 1773, 1774, 1775, 1776, 1777, 1778, 1779, 1780, 1781, 1782, 1783, 1784, 1785, 1786, 1787, 1788, 1789, 1790, 1791, 1792, 1793, 1794, 1795, 1796, 1797, 1798, 1799, 1800, 1801, 1802, 1803, 1804, 1805, 1806, 1807, 1808, 1809, 1810, 1811, 1812, 1813, 1814, 1815, 1816, 1817, 1818, 1819, 1820, 1821, 1822, 1823, 1824, 1825, 1826, 1827, 1828, 1829, 1830, 1831, 1832, 1833, 1834, 1835, 1836, 1837, 1838, 1839, 1840, 1841, 1842, 1843, 1844, 1845, 1846, 1847, 1848, 1849, 1850, 1851, 1852, 1853, 1854, 1855, 1856, 1857, 1858, 1859, 1860, 1861, 1862, 1863, 1864, 1865, 1866, 1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874, 1875, 1876, 1877, 1878, 1879, 1880, 1881, 1882, 1883, 1884, 1885, 1886, 1887, 1888, 1889, 1890, 1891, 1892, 1893, 1894, 1895, 1896, 1897, 1898, 1899, 1900, 1901, 1902, 1903, 1904, 1905, 1906, 1907, 1908, 1909, 1910, 1911, 1912, 1913, 1914, 1915, 1916, 1917, 1918, 1919, 1920, 1921, 1922, 1923, 1924, 1925, 1926, 1927, 1928, 1929, 1930, 1931, 1932, 1933, 1934, 1935, 1936, 1937, 1938, 1939, 1940, 1941, 1942, 1943, 1944, 1945, 1946, 1947, 1948, 1949, 1950, 1951, 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2030, 2031, 2032, 2033, 2034, 2035, 2036, 2037, 2038, 2039, 2040, 2041, 2042, 2043, 2044, 2045, 2046, 2047, 2048, 2049, 2050, 2051, 2052, 2053, 2054, 2055, 2056, 2057, 2058, 2059, 2060, 2061, 2062, 2063, 2064, 2065, 2066, 2067, 2068, 2069, 2070, 2071, 2072, 2073, 2074, 2075, 2076, 2077, 2078, 2079, 2080, 2081, 2082, 2083, 2084, 2085, 2086, 2087, 2088, 2089, 2090, 2091, 2092, 2093, 2094, 2095, 2096, 2097, 2098, 2099, 2100, 2101, 2102, 2103, 2104, 2105, 2106, 2107, 2108, 2109, 2110, 2111, 2112, 2113, 2114, 2115, 2116, 2117, 2118, 2119, 2120, 2121, 2122, 2123, 2124, 2125, 2126, 2127, 2128, 2129, 2130, 2131, 2132, 2133, 2134, 2135, 2136, 2137, 2138, 2139, 2140, 2141, 2142, 2143, 2144, 2145, 2146, 2147, 2148, 2149, 2150, 2151, 2152, 2153, 2154, 2155, 2156, 2157, 2158, 2159, 2160, 2161, 2162, 2163, 2164, 2165, 2166, 2167, 2168, 2169, 2170, 2171, 2172, 2173, 2174, 2175, 2176, 2177, 2178, 2179, 2180, 2181, 2182, 2183, 2184, 2185, 2186, 2187, 2188, 2189, 2190, 2191, 2192, 2193, 2194, 2195, 2196, 2197, 2198, 2199, 2200, 2201, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2216, 2217, 2218, 2219, 2220, 2221, 2222, 2223, 2224, 2225, 2226, 2227, 2228, 2229, 2230, 2231, 2232, 2233, 2234, 2235, 2236, 2237, 2238, 2239, 2240, 2241, 2242, 2243, 2244, 2245, 2246, 2247, 2248, 2249, 2250, 2251, 2252, 2253, 2254, 2255, 2256, 2257, 2258, 2259, 2260, 2261, 2262, 2263, 2264, 2265, 2266, 2267, 2268, 2269, 2270, 2271, 2272, 2273, 2274, 2275, 2276, 2277, 2278, 2279, 2280, 2281, 2282, 2283, 2284, 2285, 2286, 2287, 2288, 2289, 2290, 2291, 2292, 2293, 2294, 2295, 2296, 2297, 2298, 2299, 2300, 2301, 2302, 2303, 2304, 2305, 2306, 2307, 2308, 2309, 2310, 2311, 2312, 2313, 2314, 2315, 2316, 2317, 2318, 2319, 2320, 2321, 2322, 2323, 2324, 2325, 2326, 2327, 2328, 2329, 2330, 2331, 2332, 2333, 2334, 2335, 2336, 2337, 2338, 2339, 2340, 2341, 2342, 2343, 2344, 2345, 2346, 2347, 2348, 2349, 2350, 2351, 2352, 2353, 2354, 2355, 2356, 2357, 2358, 2359, 2360, 2361, 2362, 2363, 2364, 2365, 2366, 2367, 2368, 2369, 2370, 2371, 2372, 2373, 2374, 2375, 2376, 2377, 2378, 2379, 2380, 2381, 2382, 2383, 2384, 2385, 2386, 2387, 2388, 2389, 2390, 2391, 2392, 2393, 2394, 2395, 2396, 2397, 2398, 2399, 2400, 2401, 2402, 2403, 2404, 2405, 2406, 2407, 2408, 2409, 2410, 2411, 2412, 2413, 2414, 2415, 2416, 2417, 2418, 2419, 2420, 2421, 2422, 2423, 2424, 2425, 2426, 2427, 2428, 2429, 2430, 2431, 2432, 2433, 2434, 2435, 2436, 2437, 2438, 2439, 2440, 2441, 2442, 2443, 2444, 2445, 2446, 2447, 2448, 2449, 2450, 2451, 2452, 2453, 2454, 2455, 2456, 2457, 2458, 2459, 2460, 2461, 2462, 2463, 2464, 2465, 2466, 2467, 2468, 2469, 2470, 2471, 2472, 2473, 2474, 2475, 2476, 2477, 2478, 2479, 2480, 2481, 2482, 2483, 2484, 2485, 2486, 2487, 2488, 2489, 2490, 2491, 2492, 2493, 2494, 2495, 2496, 2497, 2498, 2499, 2500, 2501, 2502, 2503, 2504, 2505, 2506, 2507, 2508, 2509, 2510, 2511, 2512, 2513, 2514, 2515, 2516, 2517, 2518, 2519, 2520, 2521, 2522, 2523, 2524, 2525, 2526, 2527, 2528, 2529, 2530, 2531, 2532, 2533, 2534, 2535, 2536, 2537, 2538, 2539, 2540, 2541, 2542, 2543, 2544, 2545, 2546, 2547, 2548, 2549, 2550, 2551, 2552, 2553, 2554, 2555, 2556, 2557, 2558, 2559, 2560, 2561, 2562, 2563, 2564, 2565, 2566, 2567, 2568, 2569, 2570, 2571, 2572, 2573, 2574, 2575, 2576, 2577, 2578, 2579, 2580, 2581, 2582, 2583, 2584, 2585, 2586, 2587, 2588, 2589, 2590, 2591, 2592, 2593, 2594, 2595, 2596, 2597, 2598, 2599, 2600, 2601, 2602, 2603, 2604, 2605, 2606, 2607, 2608, 2609, 2610, 2611, 2612, 2613, 2614, 2615, 2616, 2617, 2618, 2619, 2620, 2621, 2622, 2623, 2624, 2625, 2626, 2627, 2628, 2629, 2630, 2631, 2632, 2633, 2634, 2635, 2636, 2637, 2638, 2639, 2640, 2641, 2642, 2643, 2644, 2645, 2646, 2647, 2648, 2649, 2650, 2651, 2652, 2653, 2654, 2655, 2656, 2657, 2658, 2659, 2660, 2661, 2662, 2663, 2664, 2665, 2666, 2667, 2668, 2669, 2670, 2671, 2672, 2673, 2674, 2675, 2676, 2677, 2678, 2679, 2680, 2681, 2682, 2683, 2684, 2685, 2686, 2687, 2688, 2689, 2690, 2691, 2692, 2693, 2694, 2695, 2696, 2697, 2698, 2699, 2700, 2701, 2702, 2703, 2704, 2705, 2706, 2707, 2708, 2709, 2710, 2711, 2712, 2713, 2714, 2715, 2716, 2717, 2718, 2719, 2720, 2721, 2722, 2723, 2724, 2725, 2726, 2727, 2728, 2729, 2730, 2731, 2732, 2733, 2734, 2735, 2736, 2737, 2738, 2739, 2740, 2741, 2742, 2743, 2744, 2745, 2746, 2747, 2748, 2749, 2750, 2751, 2752, 2753, 2754, 2755, 2756, 2757, 2758, 2759, 2760, 2761, 2762, 2763, 2764, 2765, 2766, 2767, 2768, 2769, 2770, 2771, 2772, 2773, 2774, 2775, 2776, 2777, 2778, 2779, 2780, 2781, 2782, 2783, 2784, 2785, 2786, 2787, 2788, 2789, 2790, 2791, 2792, 2793, 2794, 2795, 2796, 2797, 2798, 2799, 2800, 2801, 2802, 2803, 2804, 2805, 2806, 2807, 2808, 2809, 2810, 2811, 2812, 2813, 2814, 2815, 2816, 2817, 2818, 2819, 2820, 2821, 2822, 2823, 2824, 2825, 2826, 2827, 2828, 2829, 2830, 2831, 2832, 2833, 2834, 2835, 2836, 2837, 2838, 2839, 2840, 2841, 2842, 2843, 2844, 2845, 2846, 2847, 2848, 2849, 2850, 2851, 2852, 2853, 2854, 2855, 2856, 2857, 2858, 2859, 2860, 2861, 2862, 2863, 2864, 2865, 2866, 2867, 2868, 2869, 2870, 2871, 2872, 2873, 2874, 2875, 2876, 2877, 2878, 2879, 2880, 2881, 2882, 2883, 2884, 2885, 2886, 2887, 2888, 2889, 2890, 2891, 2892, 2893, 2894, 2895, 2896, 2897, 2898, 2899, 2900, 2901, 2902, 2903, 2904, 2905, 2906, 2907, 2908, 2909, 2910, 2911, 2912, 2913, 2914, 2915, 2916, 2917, 2918, 2919, 2920, 2921, 2922, 2923, 2924, 2925, 2926, 2927, 2928, 2929, 2930, 2931, 2932, 2933, 2934, 2935, 2936, 2937, 2938, 2939, 2940, 2941, 2942, 2943, 2944, 2945, 2946, 2947, 2948, 2949, 2950, 2951, 2952, 2953, 2954, 2955, 2956, 2957, 2958, 2959, 2960, 2961, 2962, 2963, 2964, 2965, 2966, 2967, 2968, 2969, 2970, 2971, 2972, 2973, 2974, 2975, 2976, 2977, 2978, 2979, 2980, 2981, 2982, 2983, 2984, 2985, 2986, 2987, 2988, 2989, 2990, 2991, 2992, 2993, 2994, 2995, 2996, 2997, 2998, 2999, 3000, 3001, 3002, 3003, 3004, 3005, 3006, 3007, 3008, 3009, 3010, 3011, 3012, 3013, 3014, 3015, 3016, 3017, 3018, 3019, 3020, 3021, 3022, 3023, 3024, 3025, 3026, 3027, 3028, 3029, 3030, 3031, 3032, 3033, 3034, 3035, 3036, 3037, 3038, 3039, 3040, 3041, 3042, 3043, 3044, 3045, 3046, 3047, 3048, 3049, 3050, 3051, 3052, 3053, 3054, 3055, 3056, 3057, 3058, 3059, 3060, 3061, 3062, 3063, 3064, 3065, 3066, 3067, 3068, 3069, 3070, 3071, 3072, 3073, 3074, 3075, 3076, 3077, 3078, 3079, 3080, 3081, 3082, 3083, 3084, 3085, 3086, 3087, 3088, 3089, 3090, 3091, 3092, 3093, 3094, 3095, 3096, 3097, 3098, 3099, 3100, 3101, 3102, 3103, 3104, 3105, 3106, 3107, 3108, 3109, 3110, 3111, 3112, 3113, 3114, 3115, 3116, 3117, 3118, 3119, 3120, 3121, 3122, 3123, 3124, 3125, 3126, 3127, 3128, 3129, 3130, 3131, 3132, 3133, 3134, 3135, 3136, 3137, 3138, 3139, 3140, 3141, 3142, 3143, 3144, 3145, 3146, 3147, 3148, 3149, 3150, 3151, 3152, 3153, 3154, 3155, 3156, 3157, 3158, 3159, 3160, 3161, 3162, 3163, 3164, 3165, 3166, 3167, 3168, 3169, 3170, 3171, 3172, 3173, 3174, 3175, 3176, 3177, 3178, 3179, 3180, 3181, 3182, 3183, 3184, 3185, 3186, 3187, 3188, 3189, 3190, 3191, 3192, 3193, 3194, 3195, 3196, 3197, 3198, 3199, 3200, 3201, 3202, 3203, 3204, 3205, 3206, 3207, 3208, 3209, 3210, 3211, 3212, 3213, 3214, 3215, 3216, 3217, 3218, 3219, 3220, 3221, 3222, 3223, 3224, 3225, 3226, 3227, 3228, 3229, 3230, 3231, 3232, 3233, 3234, 3235, 3236, 3237, 3238, 3239, 3240, 3241, 3242, 3243, 3244, 3245, 3246, 3247, 3248, 3249, 3250, 3251, 3252, 3253, 3254, 3255, 3256, 3257, 3258, 3259, 3260, 3261, 3262, 3263, 3264, 3265, 3266, 3267, 3268, 3269, 3270, 3271, 3272, 3273, 3274, 3275, 3276, 3277, 3278, 3279, 3280, 3281, 3282, 3283, 3284, 3285, 3286, 3287, 3288, 3289, 3290, 3291, 3292, 3293, 3294, 3295, 3296, 3297, 3298, 3299, 3300, 3301, 3302, 3303, 3304, 3305, 3306, 3307, 3308, 3309, 3310, 3311, 3312, 3313, 3314, 3315, 3316, 3317, 3318, 3319, 3320, 3321, 3322, 3323, 3324, 3325, 3326, 3327, 3328, 3329, 3330, 3331, 3332, 3333, 3334, 3335, 3336, 3337, 3338, 3339, 3340, 3341, 3342, 3343, 3344, 3345, 3346, 3347, 3348, 3349, 3350, 3351, 3352, 3353, 3354, 3355, 3356, 3357, 3358, 3359, 3360, 3361, 3362, 3363, 3364, 3365, 3366, 3367, 3368, 3369, 3370, 3371, 3372, 3373, 3374, 3375, 3376, 3377, 3378, 3379, 3380, 3381, 3382, 3383, 3384, 3385, 3386, 3387, 3388, 3389, 3390, 3391, 3392, 3393, 3394, 3395, 3396, 3397, 3398, 3399, 3400, 3401, 3402, 3403, 3404, 3405, 3406, 3407, 3408, 3409, 3410, 3411, 3412, 3413, 3414, 3415, 3416, 3417, 3418, 3419, 3420, 3421, 3422, 3423, 3424, 3425, 3426, 3427, 3428, 3429, 3430, 3431, 3432, 3433, 3434, 3435, 3436, 3437, 3438, 3439, 3440, 3441, 3442, 3443, 3444, 3445, 3446, 3447, 3448, 3449, 3450, 3451, 3452, 3453, 3454, 3455, 3456, 3457, 3458, 3459, 3460, 3461, 3462, 3463, 3464, 3465, 3466, 3467, 3468, 3469, 3470, 3471, 3472, 3473, 3474, 3475, 3476, 3477, 3478, 3479, 3480, 3481, 3482, 3483, 3484, 3485, 3486, 3487, 3488, 3489, 3490, 3491, 3492, 3493, 3494, 3495, 3496, 3497, 3498, 3499, 3500, 3501, 3502, 3503, 3504, 3505, 3506, 3507, 3508, 3509, 3510, 3511, 3512, 3513, 3514, 3515, 3516, 3517, 3518, 3519, 3520, 3521, 3522, 3523, 3524, 3525, 3526, 3527, 3528, 3529, 3530, 3531, 3532, 3533, 3534, 3535, 3536, 3537, 3538, 3539, 3540, 3541, 3542, 3543, 3544, 3545, 3546, 3547, 3548, 3549, 3550, 3551, 3552, 3553, 3554, 3555, 3556, 3557, 3558, 3559, 3560, 3561, 3562, 3563, 3564, 3565, 3566, 3567, 3568, 3569, 3570, 3571, 3572, 3573, 3574, 3575, 3576, 3577, 3578, 3579, 3580, 3581, 3582, 3583, 3584, 3585, 3586, 3587, 3588, 3589, 3590, 3591, 3592, 3593, 3594, 3595, 3596, 3597, 3598, 3599, 3600, 3601, 3602, 3603, 3604, 3605, 3606, 3607, 3608, 3609, 3610, 3611, 3612, 3613, 3614, 3615, 3616, 3617, 3618, 3619, 3620, 3621, 3622, 3623, 3624, 3625, 3626, 3627, 3628, 3629, 3630, 3631, 3632, 3633, 3634, 3635, 3636, 3637, 3638, 3639, 3640, 3641, 3642, 3643, 3644, 3645, 3646, 3647, 3648, 3649, 3650, 3651, 3652, 3653, 3654, 3655, 3656, 3657, 3658, 3659, 3660, 3661, 3662, 3663, 3664, 3665, 3666, 3667, 3668, 3669, 3670, 3671, 3672, 3673, 3674, 3675, 3676, 3677, 3678, 3679, 3680, 3681, 3682, 3683, 3684, 3685, 3686, 3687, 3688, 3689, 3690, 3691, 3692, 3693, 3694, 3695, 3696, 3697, 3698, 3699, 3700, 3701, 3702, 3703, 3704, 3705, 3706, 3707, 3708, 3709, 3710, 3711, 3712, 3713, 3714, 3715, 3716, 3717, 3718, 3719, 3720, 3721, 3722, 3723, 3724, 3725, 3726, 3727, 3728, 3729, 3730, 3731, 3732, 3733, 3734, 3735, 3736, 3737, 3738, 3739, 3740, 3741, 3742, 3743, 3744, 3745, 3746, 3747, 3748, 3749, 3750, 3751, 3752, 3753, 3754, 3755, 3756, 3757, 3758, 3759, 3760, 3761, 3762, 3763, 3764, 3765, 3766, 3767, 3768, 3769, 3770, 3771, 3772, 3773, 3774, 3775, 3776, 3777, 3778, 3779, 3780, 3781, 3782, 3783, 3784, 3785, 3786, 3787, 3788, 3789, 3790, 3791, 3792, 3793, 3794, 3795, 3796, 3797, 3798, 3799, 3800, 3801, 3802, 3803, 3804, 3805, 3806, 3807, 3808, 3809, 3810, 3811, 3812, 3813, 3814, 3815, 3816, 3817, 3818, 3819, 3820, 3821, 3822, 3823, 3824, 3825, 3826, 3827, 3828, 3829, 3830, 3831, 3832, 3833, 3834, 3835, 3836, 3837, 3838, 3839, 3840, 3841, 3842, 3843, 3844, 3845, 3846, 3847, 3848, 3849, 3850, 3851, 3852, 3853, 3854, 3855, 3856, 3857, 3858, 3859, 3860, 3861, 3862, 3863, 3864, 3865, 3866, 3867, 3868, 3869, 3870, 3871, 3872, 3873, 3874, 3875, 3876, 3877, 3878, 3879, 3880, 3881, 3882, 3883, 3884, 3885, 3886, 3887, 3888, 3889, 3890, 3891, 3892, 3893, 3894, 3895, 3896, 3897, 3898, 3899, 3900, 3901, 3902, 3903, 3904, 3905, 3906, 3907, 3908, 3909, 3910, 3911, 3912, 3913, 3914, 3915, 3916, 3917, 3918, 3919, 3920, 3921, 3922, 3923, 3924, 3925, 3926, 3927, 3928, 3929, 3930, 3931, 3932, 3933, 3934, 3935, 3936, 3937, 3938, 3939, 3940, 3941, 3942, 3943, 3944, 3945, 3946, 3947, 3948, 3949, 3950, 3951, 3952, 3953, 3954, 3955, 3956, 3957, 3958, 3959, 3960, 3961, 3962, 3963, 3964, 3965, 3966, 3967, 3968, 3969, 3970, 3971, 3972, 3973, 3974, 3975, 3976, 3977, 3978, 3979, 3980, 3981, 3982, 3983, 3984, 3985, 3986, 3987, 3988, 3989, 3990, 3991, 3992, 3993, 3994, 3995, 3996, 3997, 3998, 3999, 4000, 4001, 4002, 4003, 4004, 4005, 4006, 4007, 4008, 4009, 4010, 4011, 4012, 4013, 4014, 4015, 4016, 4017, 4018, 4019, 4020, 4021, 4022, 4023, 4024, 4025, 4026, 4027, 4028, 4029, 4030, 4031, 4032, 4033, 4034, 4035, 4036, 4037, 4038], [686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 795, 796, 797, 798, 799, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, 844, 845, 846, 847, 848, 849, 850, 851, 852, 853, 854, 855, 856, 858, 859, 860, 861, 863, 864, 866, 867, 869, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895]]
In [89]:
plot_community_subgraph(G_fbsocial, community_node_groups_fb)
G_fbsocial Greedy modularity
In [47]:
greed_community_fb = greedy_modularity_communities(G_fbsocial)
greed_list_fb = list(greed_community_fb)
print("number of communities is", len(list(greed_community_fb)))
print(greed_list_fb)
number of communities is 13
[frozenset({3261, 3271, 3277, 3280, 3281, 3282, 3291, 3292, 1290, 3330, 3335, 3336, 3337, 3338, 3350, 1317, 3354, 1321, 1323, 1325, 1327, 3368, 3373, 3376, 3378, 2661, 2662, 2665, 3379, 2667, 2668, 3380, 2671, 2672, 2674, 2675, 3381, 2677, 2678, 2975, 2682, 2684, 2685, 2686, 2687, 2688, 3383, 2690, 2691, 2692, 2693, 2696, 2697, 2700, 2701, 2702, 3038, 2707, 2708, 2709, 2711, 2712, 2713, 2714, 2715, 2716, 2718, 2719, 2720, 2721, 2722, 2723, 2724, 2725, 2727, 2728, 2730, 2732, 2733, 2734, 2735, 2736, 2737, 2739, 2742, 2744, 2747, 2748, 2751, 2752, 2753, 2758, 2759, 2760, 2762, 2764, 2765, 2768, 3122, 2770, 2771, 2772, 1365, 2775, 2776, 3401, 2778, 2779, 2780, 2781, 3402, 2783, 2784, 2785, 3403, 2787, 2788, 2790, 2791, 2792, 2793, 2795, 2796, 2797, 2799, 2801, 2802, 2803, 2804, 2805, 3407, 2808, 2811, 2812, 2813, 2816, 2818, 2819, 2820, 2822, 2823, 2824, 2825, 2826, 2828, 2829, 2830, 2831, 2832, 2833, 2836, 2840, 2841, 2842, 2843, 2844, 2845, 2846, 2847, 2848, 2849, 3416, 2853, 2855, 2856, 2857, 2858, 2859, 2860, 2861, 2863, 2865, 2868, 2869, 2870, 2871, 3013, 2875, 2876, 3421, 2878, 2881, 2882, 2883, 2886, 2889, 2892, 2893, 2894, 2895, 2898, 2900, 2901, 2902, 2903, 2904, 2914, 2918, 2921, 2922, 2923, 2926, 2930, 2932, 2933, 2934, 2935, 2936, 2937, 2938, 2939, 2941, 2942, 897, 2946, 899, 2947, 2949, 2950, 2951, 2952, 906, 2954, 908, 2955, 2957, 2958, 2961, 2962, 2964, 916, 2965, 2968, 920, 2970, 921, 2971, 2973, 922, 925, 926, 923, 2976, 927, 928, 2979, 932, 929, 934, 2980, 2983, 2984, 2989, 2990, 2991, 2992, 946, 947, 2995, 2996, 950, 2999, 952, 3001, 953, 951, 2997, 3005, 2998, 959, 960, 961, 3002, 3011, 3006, 3007, 966, 967, 3009, 3012, 970, 3019, 3020, 972, 973, 3015, 3016, 3017, 978, 3018, 980, 3021, 982, 983, 3024, 3027, 3034, 3031, 3028, 3032, 990, 991, 3035, 993, 3037, 995, 996, 997, 998, 999, 3039, 3041, 3043, 1003, 1004, 3046, 1006, 3048, 1008, 3057, 3049, 3050, 3051, 3053, 3062, 3058, 3060, 1017, 3061, 3063, 3066, 3067, 3068, 1023, 1024, 3071, 1026, 3069, 1028, 1029, 3072, 3079, 1031, 1033, 1034, 3075, 3076, 3077, 1038, 1039, 1040, 3082, 3083, 3086, 3087, 3088, 3089, 1047, 1048, 3097, 1049, 1050, 3100, 3101, 1054, 1055, 1056, 3099, 1058, 1059, 3102, 1061, 3103, 3111, 1063, 3105, 3106, 3107, 1068, 1069, 3109, 3110, 3112, 1073, 1074, 1075, 1076, 3116, 1078, 1079, 3120, 3121, 3124, 1083, 1084, 3125, 1086, 1087, 3136, 1088, 3131, 1091, 1092, 3132, 3133, 3134, 3138, 3140, 1098, 3141, 3144, 1101, 3145, 3146, 3148, 3150, 3151, 1107, 3152, 3154, 1110, 3155, 1112, 3157, 3162, 3159, 3164, 3165, 1116, 1117, 3168, 3161, 3167, 1123, 1124, 3173, 1125, 1126, 1128, 3169, 3178, 3179, 1132, 1133, 1130, 1135, 1136, 3183, 3186, 3182, 1140, 3185, 3187, 3191, 1144, 3192, 1146, 3188, 3196, 1149, 1150, 3197, 3198, 3201, 1153, 3199, 1156, 3205, 3200, 1157, 1160, 1161, 3208, 1163, 1164, 1165, 3210, 3211, 3212, 3214, 3215, 3216, 1172, 1173, 3222, 1174, 1175, 3217, 1178, 3223, 1180, 1181, 1182, 3230, 1184, 3233, 1185, 1187, 3227, 3235, 3236, 1191, 3239, 3240, 3241, 1195, 3242, 3245, 1198, 1199, 3248, 1201, 3244, 3246, 3247, 1205, 3249, 1207, 3251, 1209, 3258, 1211, 3252, 3253, 1214, 3263, 3091, 3265, 3259, 1219, 1220, 3260, 1222, 3262, 3264, 3266, 3093, 3267, 3268, 3270, 3278, 3094, 1230, 3272, 3273, 3274, 3275, 3276, 1238, 1239, 3279, 3289, 1242, 1243, 3285, 3287, 3288, 3295, 3296, 3297, 1250, 1251, 3298, 3299, 3302, 1255, 3304, 1256, 3305, 3307, 3308, 3306, 3310, 3312, 1265, 1266, 1267, 3313, 1269, 3316, 3319, 1271, 1272, 1274, 3320, 3321, 3322, 1278, 3323, 3328, 1280, 3326, 3331, 1283, 1285, 3327, 1287, 1288, 1289, 3329, 1291, 3332, 1293, 3334, 3340, 3342, 3344, 3343, 3345, 3341, 1301, 1302, 3347, 3349, 1305, 3346, 3355, 1307, 3351, 3358, 3352, 1312, 3361, 3353, 3356, 3357, 3360, 3366, 3367, 3359, 3369, 3370, 1077, 3371, 3365, 3372, 3375, 3113, 1329, 1328, 1331, 1330, 3374, 3377, 1335, 1336, 3385, 3386, 3115, 1337, 1341, 1340, 1339, 1344, 3393, 1346, 3117, 3391, 3389, 3398, 1351, 3118, 1352, 3395, 3396, 3404, 3397, 3406, 1359, 1360, 3409, 3410, 1361, 3412, 3411, 3405, 1367, 3408, 1369, 1370, 3415, 3420, 3419, 3422, 1375, 1376, 1377, 3418, 3425, 1380, 3427, 3424, 1383, 3429, 3431, 3434, 3432, 1388, 1389, 1390, 1391, 3126, 1393, 1398, 1399, 1401, 1402, 3128, 1405, 1407, 1409, 1410, 1411, 1416, 1419, 1420, 1421, 1431, 1433, 1434, 1437, 1439, 1440, 1441, 1442, 1445, 1447, 1449, 1450, 1456, 3070, 1457, 1458, 1460, 1461, 1463, 1467, 1470, 1471, 1476, 1477, 1480, 1483, 1484, 1485, 1488, 1491, 1494, 1498, 1501, 1505, 1509, 1511, 1513, 1516, 1517, 1518, 1519, 1520, 1521, 1522, 1523, 1524, 1527, 1528, 1530, 1532, 1534, 1535, 1537, 1538, 1539, 1542, 3156, 1544, 1547, 1551, 1552, 1553, 1554, 1555, 1556, 1557, 1559, 1561, 1563, 1564, 3160, 1567, 1570, 1571, 1572, 1579, 1580, 1584, 1585, 1588, 1589, 1590, 1593, 1594, 1597, 1598, 1600, 1603, 1604, 1605, 1608, 1609, 1610, 1612, 1613, 3170, 1614, 1615, 1617, 1618, 3171, 1619, 1620, 1621, 1622, 1623, 3172, 1626, 1632, 1637, 3175, 1639, 1641, 1642, 1643, 1644, 3176, 3177, 1651, 1652, 1653, 1656, 1659, 1662, 1663, 3180, 1665, 1666, 1668, 1669, 1670, 3181, 1674, 1675, 1676, 1678, 1683, 1684, 1685, 1687, 1688, 1689, 1697, 1698, 1700, 1701, 1702, 1705, 1707, 1708, 3189, 1710, 1712, 1714, 3190, 1717, 1719, 1721, 1722, 1723, 1724, 1726, 1730, 1734, 1735, 1736, 1737, 3081, 3194, 1741, 1746, 1750, 1752, 1753, 1754, 1757, 1758, 1761, 1765, 1768, 1769, 1771, 1772, 1774, 1775, 1779, 1780, 3203, 1782, 3204, 1789, 1791, 1792, 1793, 1795, 1796, 1797, 3206, 1799, 1800, 3207, 1803, 1804, 1805, 1806, 1809, 1810, 1811, 3209, 1813, 1816, 1817, 1819, 1821, 1822, 1823, 1825, 1826, 1827, 1832, 1833, 1835, 1836, 1838, 1839, 1842, 1843, 1845, 1846, 1849, 1851, 1852, 1854, 3218, 1856, 1858, 1860, 1861, 3219, 1863, 1864, 1865, 1866, 1867, 1868, 3221, 1874, 1877, 1879, 1883, 3224, 1886, 1888, 3225, 1891, 1898, 1900, 1902, 1905, 1908, 1909, 1911, 1196, 3254, 3255, 3256}), frozenset({107, 348, 349, 350, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 394, 395, 396, 397, 398, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 455, 456, 457, 458, 459, 460, 461, 462, 463, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 579, 580, 581, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 596, 597, 598, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 629, 630, 631, 633, 634, 636, 637, 638, 639, 641, 642, 644, 645, 646, 648, 649, 651, 652, 653, 654, 655, 656, 657, 660, 663, 664, 666, 667, 668, 669, 671, 672, 673, 674, 676, 677, 678, 679, 680, 682, 683, 684, 685, 896, 898, 900, 902, 904, 905, 907, 909, 910, 911, 912, 913, 914, 915, 917, 918, 919, 924, 930, 931, 933, 935, 936, 937, 939, 940, 941, 942, 943, 944, 945, 948, 949, 954, 955, 956, 957, 962, 964, 965, 968, 969, 971, 974, 975, 976, 977, 979, 981, 984, 985, 986, 987, 988, 989, 994, 1000, 1001, 1002, 1005, 1007, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1018, 1019, 1020, 1021, 1022, 1025, 1027, 1030, 1032, 1035, 1036, 1037, 1041, 1042, 1043, 1044, 1045, 1046, 1051, 1052, 1053, 1057, 1060, 1062, 1064, 1065, 1066, 1067, 1070, 1071, 1072, 1080, 1081, 1082, 1089, 1090, 1093, 1094, 1095, 1096, 1099, 1100, 1102, 1103, 1104, 1105, 1106, 1108, 1109, 1111, 1113, 1114, 1115, 1119, 1120, 1121, 1122, 1127, 1129, 1131, 1134, 1138, 1139, 1141, 1142, 1143, 1145, 1147, 1148, 1151, 1152, 1154, 1155, 1158, 1159, 1162, 1166, 1167, 1168, 1169, 1170, 1176, 1177, 1179, 1183, 1188, 1189, 1190, 1192, 1194, 1197, 1200, 1202, 1203, 1204, 1206, 1208, 1210, 1212, 1213, 1215, 1217, 1218, 1221, 1223, 1224, 1225, 1226, 1227, 1228, 1229, 1231, 1233, 1234, 1235, 1236, 1237, 1240, 1241, 1244, 1245, 1246, 1247, 1248, 1249, 1252, 1253, 1254, 1257, 1258, 1259, 1260, 1261, 1262, 1263, 1264, 1268, 1270, 1273, 1275, 1276, 1277, 1279, 1281, 1282, 1284, 1286, 1292, 1294, 1295, 1296, 1298, 1299, 1300, 1303, 1304, 1306, 1308, 1309, 1310, 1311, 1313, 1315, 1316, 1318, 1320, 1322, 1324, 1326, 1332, 1334, 1338, 1342, 1343, 1345, 1347, 1348, 1349, 1350, 1353, 1354, 1355, 1356, 1357, 1358, 1362, 1364, 1366, 1368, 1371, 1372, 1373, 1374, 1379, 1381, 1382, 1384, 1385, 1386, 1392, 1394, 1395, 1396, 1397, 1400, 1403, 1404, 1406, 1408, 1412, 1413, 1414, 1415, 1417, 1418, 1422, 1423, 1425, 1426, 1427, 1428, 1429, 1430, 1432, 1435, 1436, 1438, 1443, 1444, 1446, 1448, 1451, 1453, 1454, 1455, 1459, 1462, 1464, 1466, 1469, 1472, 1473, 1474, 1475, 1478, 1479, 1481, 1482, 1487, 1489, 1490, 1492, 1495, 1496, 1497, 1499, 1500, 1502, 1503, 1504, 1506, 1507, 1508, 1510, 1512, 1514, 1515, 1525, 1526, 1529, 1531, 1536, 1540, 1541, 1543, 1545, 1546, 1550, 1558, 1560, 1562, 1565, 1566, 1569, 1573, 1574, 1575, 1576, 1578, 1581, 1582, 1583, 1586, 1587, 1591, 1592, 1595, 1596, 1599, 1602, 1606, 1607, 1611, 1616, 1624, 1625, 1627, 1628, 1630, 1631, 1633, 1634, 1635, 1636, 1638, 1640, 1645, 1646, 1647, 1649, 1650, 1654, 1655, 1657, 1658, 1660, 1661, 1664, 1667, 1671, 1672, 1673, 1677, 1679, 1680, 1681, 1682, 1686, 1690, 1691, 1692, 1693, 1694, 1695, 1696, 1699, 1703, 1704, 1706, 1709, 1711, 1713, 1715, 1716, 1720, 1725, 1727, 1728, 1729, 1731, 1732, 1738, 1739, 1740, 1742, 1743, 1744, 1745, 1748, 1749, 1751, 1755, 1756, 1759, 1760, 1762, 1763, 1764, 1766, 1767, 1770, 1773, 1776, 1777, 1778, 1781, 1783, 1785, 1786, 1788, 1790, 1794, 1801, 1807, 1808, 1812, 1814, 1815, 1818, 1820, 1824, 1828, 1829, 1830, 1831, 1834, 1840, 1841, 1844, 1847, 1848, 1850, 1853, 1855, 1857, 1859, 1862, 1869, 1870, 1871, 1872, 1873, 1875, 1876, 1878, 1881, 1882, 1884, 1885, 1887, 1889, 1890, 1893, 1894, 1896, 1897, 1899, 1901, 1903, 1904, 1906, 1907, 1910, 1967}), frozenset({857, 862, 865, 868, 1085, 3437, 3438, 3439, 3440, 3441, 3442, 3443, 3444, 3445, 3446, 3447, 3448, 3449, 3450, 3451, 3452, 3453, 3454, 3455, 3456, 3457, 3458, 3459, 3460, 3461, 3462, 3463, 3464, 3465, 3466, 3467, 3468, 3469, 3470, 3471, 3472, 3473, 3474, 3475, 3476, 3477, 3478, 3479, 3480, 3481, 3482, 3483, 3484, 3485, 3486, 3487, 3488, 3489, 3490, 3491, 3492, 3493, 3494, 3495, 3496, 3497, 3498, 3499, 3500, 3501, 3502, 3503, 3504, 3505, 3506, 3507, 3508, 3509, 3510, 3511, 3512, 3513, 3514, 3515, 3516, 3517, 3518, 3519, 3520, 3521, 3522, 3523, 3524, 3525, 3526, 3527, 3528, 3529, 3530, 3531, 3532, 3533, 3534, 3535, 3536, 3537, 3538, 3539, 3540, 3541, 3542, 3543, 3544, 3545, 3546, 3547, 3548, 3549, 3550, 3551, 3552, 3553, 3554, 3555, 3556, 3557, 3558, 3559, 3560, 3561, 3562, 3563, 3564, 3565, 3566, 3567, 3568, 3569, 3570, 3571, 3572, 3573, 3574, 3575, 3576, 3577, 3578, 3579, 3580, 3581, 3582, 3583, 3584, 3585, 3586, 3587, 3588, 3589, 3590, 3591, 3592, 3593, 3594, 3595, 3596, 3597, 3598, 3599, 3600, 3601, 3602, 3603, 3604, 3605, 3606, 3607, 3608, 3609, 3610, 3611, 3612, 3613, 3614, 3615, 3616, 3617, 3618, 3619, 3620, 3621, 3622, 3623, 3624, 3625, 3626, 3627, 3628, 3629, 3630, 3631, 3632, 3633, 3634, 3635, 3636, 3637, 3638, 3639, 3640, 3641, 3642, 3643, 3644, 3645, 3646, 3647, 3648, 3649, 3650, 3651, 3652, 3653, 3654, 3655, 3656, 3657, 3658, 3659, 3660, 3661, 3662, 3663, 3664, 3665, 3666, 3667, 3668, 3669, 3670, 3671, 3672, 3673, 3674, 3675, 3676, 3677, 3678, 3679, 3680, 3681, 3682, 3683, 3684, 3685, 3686, 3687, 3688, 3689, 3690, 3691, 3692, 3693, 3694, 3695, 3696, 3697, 3698, 3699, 3700, 3701, 3702, 3703, 3704, 3705, 3706, 3707, 3708, 3709, 3710, 3711, 3712, 3713, 3714, 3715, 3716, 3717, 3718, 3719, 3720, 3721, 3722, 3723, 3724, 3725, 3726, 3727, 3728, 3729, 3730, 3731, 3732, 3733, 3734, 3735, 3736, 3737, 3738, 3739, 3740, 3741, 3742, 3743, 3744, 3745, 3746, 3747, 3748, 3749, 3750, 3751, 3752, 3753, 3754, 3755, 3756, 3757, 3758, 3759, 3760, 3761, 3762, 3763, 3764, 3765, 3766, 3767, 3768, 3769, 3770, 3771, 3772, 3773, 3774, 3775, 3776, 3777, 3778, 3779, 3780, 3781, 3782, 3783, 3784, 3785, 3786, 3787, 3788, 3789, 3790, 3791, 3792, 3793, 3794, 3795, 3796, 3797, 3798, 3799, 3800, 3801, 3802, 3803, 3804, 3805, 3806, 3807, 3808, 3809, 3810, 3811, 3812, 3813, 3814, 3815, 3816, 3817, 3818, 3819, 3820, 3821, 3822, 3823, 3824, 3825, 3826, 3827, 3828, 3829, 3830, 3831, 3832, 3833, 3834, 3835, 3836, 3837, 3838, 3839, 3840, 3841, 3842, 3843, 3844, 3845, 3846, 3847, 3848, 3849, 3850, 3851, 3852, 3853, 3854, 3855, 3856, 3857, 3858, 3859, 3860, 3861, 3862, 3863, 3864, 3865, 3866, 3867, 3868, 3869, 3870, 3871, 3872, 3873, 3874, 3875, 3876, 3877, 3878, 3879, 3880, 3881, 3882, 3883, 3884, 3885, 3886, 3887, 3888, 3889, 3890, 3891, 3892, 3893, 3894, 3895, 3896, 3897, 3898, 3899, 3900, 3901, 3902, 3903, 3904, 3905, 3906, 3907, 3908, 3909, 3910, 3911, 3912, 3913, 3914, 3915, 3916, 3917, 3918, 3919, 3920, 3921, 3922, 3923, 3924, 3925, 3926, 3927, 3928, 3929, 3930, 3931, 3932, 3933, 3934, 3935, 3936, 3937, 3938, 3939, 3940, 3941, 3942, 3943, 3944, 3945, 3946, 3947, 3948, 3949, 3950, 3951, 3952, 3953, 3954, 3955, 3956, 3957, 3958, 3959, 3960, 3961, 3962, 3963, 3964, 3965, 3966, 3967, 3968, 3969, 3970, 3971, 3972, 3973, 3974, 3975, 3976, 3977, 3978, 3979}), frozenset({2048, 2049, 2050, 2051, 2052, 2053, 2054, 2057, 2058, 2061, 2062, 2065, 2066, 2067, 2068, 2070, 2071, 2072, 2075, 2076, 2079, 2080, 2081, 2082, 2085, 2087, 2089, 2091, 2092, 2094, 2096, 2097, 2099, 2100, 2101, 2102, 2105, 2106, 2107, 2110, 2111, 2113, 2114, 2116, 2117, 2119, 2120, 2125, 2126, 2127, 2128, 2129, 2130, 2132, 2133, 2134, 2135, 2137, 2138, 2141, 2143, 2144, 2145, 2146, 2147, 2148, 2149, 2151, 2152, 2153, 2155, 2156, 2157, 2158, 2159, 2160, 2161, 2162, 2163, 2166, 2167, 2168, 2169, 2170, 2171, 2173, 2174, 2175, 2176, 2177, 2178, 2180, 2181, 2182, 2183, 2185, 2186, 2187, 2189, 2191, 2192, 2193, 2194, 2195, 2196, 2197, 2198, 2199, 2202, 2203, 2204, 2205, 2207, 2208, 2209, 2211, 2214, 2215, 2217, 2219, 2221, 2222, 2223, 2224, 2225, 2226, 2227, 2228, 2230, 2231, 2232, 2234, 2235, 2236, 2238, 2239, 2241, 2242, 2243, 2245, 2246, 2247, 2248, 2249, 2250, 2251, 2252, 2254, 2255, 2256, 2259, 2260, 2262, 2263, 2264, 2265, 2267, 2268, 2269, 2270, 2272, 2273, 2274, 2277, 2279, 2280, 2281, 2282, 2283, 2284, 2285, 2286, 2288, 2289, 2291, 2292, 2293, 2294, 2295, 2296, 2297, 2298, 2301, 2302, 2303, 2304, 2305, 2310, 2312, 2313, 2314, 2315, 2316, 2317, 2318, 2319, 2320, 2321, 2322, 2325, 2327, 2328, 2330, 2332, 2333, 2335, 2336, 2337, 2338, 2341, 2342, 2343, 2344, 2345, 2346, 2347, 2349, 2350, 2351, 2355, 2357, 2358, 2360, 2361, 2362, 2364, 2365, 2366, 2367, 2368, 2371, 2372, 2373, 2375, 2377, 2378, 2379, 2380, 2382, 2383, 2384, 2385, 2387, 2388, 2389, 2390, 2391, 2393, 2394, 2396, 2397, 2398, 2399, 2400, 2401, 2402, 2403, 2405, 2406, 2411, 2412, 2413, 2415, 2416, 2417, 2419, 2420, 2421, 2422, 2424, 2425, 2426, 2427, 2429, 2431, 2432, 2434, 2435, 2436, 2437, 2438, 2439, 2440, 2441, 2443, 2444, 2445, 2447, 2448, 2449, 2450, 2451, 2452, 2453, 2454, 2455, 2456, 2457, 2458, 2459, 2461, 2463, 2465, 2466, 2468, 2470, 2471, 2472, 2473, 2474, 2475, 2476, 2478, 2479, 2480, 2481, 2483, 2486, 2487, 2488, 2490, 2491, 2493, 2494, 2496, 2497, 2498, 2501, 2502, 2503, 2505, 2508, 2509, 2510, 2511, 2512, 2513, 2514, 2515, 2516, 2517, 2518, 2519, 2522, 2523, 2525, 2527, 2528, 2529, 2530, 2531, 2533, 2534, 2535, 2537, 2538, 2540, 2541, 2543, 2544, 2545, 2547, 2548, 2555, 2557, 2558, 2562, 2565, 2566, 2567, 2568, 2569, 2570, 2571, 2572, 2576, 2577, 2580, 2581, 2582, 2583, 2584, 2585, 2587, 2588, 2589, 2592, 2594, 2595, 2596, 2597, 2598, 2599, 2603, 2605, 2608, 2609, 2610, 2612, 2614, 2616, 2617, 2618, 2620, 2621, 2622, 2626, 2627, 2628, 2629, 2632, 2633, 2634, 2635, 2636, 2637, 2639, 2640, 2641, 2642, 2643, 2644, 2645, 2647, 2648, 2649, 2650, 2651, 2652, 2653, 2656, 2657, 2658, 2659, 2660, 1465, 1577, 1718, 1912, 1913, 1914, 1915, 1916, 1919, 1920, 1921, 1922, 1923, 1924, 1926, 1927, 1928, 1930, 1931, 1932, 1933, 1934, 1935, 1936, 1937, 1939, 1940, 1941, 1942, 1944, 1945, 1947, 1948, 1949, 1950, 1951, 1952, 1954, 1955, 1956, 1957, 1958, 1959, 1960, 1961, 1964, 1965, 1968, 1969, 1970, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1980, 1981, 1982, 1987, 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2031, 2032, 2034, 2035, 2036, 2038, 2039, 2041, 2042, 2044, 2047}), frozenset({0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 351, 364, 393, 399, 427, 441, 454, 464, 476, 501, 549, 564, 2704, 2740, 2814, 2838, 2885, 3003, 1171, 1193, 3290, 1297, 1387, 1486, 1549}), frozenset({3073, 3078, 3080, 3084, 3085, 3090, 3092, 3095, 3096, 3098, 3104, 3108, 3114, 3119, 3123, 3129, 3130, 3135, 3137, 3139, 3142, 3143, 3149, 3153, 3158, 3163, 3166, 3174, 2663, 2664, 2666, 2669, 3184, 2673, 2676, 2679, 2680, 2681, 3193, 2683, 3195, 2689, 3202, 2694, 2695, 2698, 3213, 2705, 2706, 3220, 2710, 3226, 3228, 3229, 2717, 3231, 3232, 3234, 3237, 3238, 2726, 2729, 3243, 2731, 3250, 2738, 2741, 2743, 3257, 2745, 2746, 2749, 2750, 2754, 2755, 2756, 3269, 2757, 2761, 2763, 2766, 2769, 3284, 2773, 3286, 2777, 3293, 3294, 2782, 2786, 3300, 3301, 2789, 3303, 2794, 2798, 2800, 3315, 3317, 2806, 2807, 2809, 2810, 3324, 2815, 3333, 2821, 3339, 2827, 2835, 3348, 2837, 2839, 3362, 3363, 3364, 2850, 2851, 2852, 2854, 2862, 2864, 2866, 2867, 3384, 2872, 2873, 3387, 3388, 2874, 3390, 2877, 3392, 2880, 3394, 2884, 3399, 3400, 2887, 2888, 2890, 2891, 2896, 2897, 2899, 3413, 3414, 3417, 2905, 2906, 2907, 2908, 2909, 2910, 2911, 2912, 3426, 2913, 3428, 2915, 3430, 2916, 2917, 3433, 2919, 3435, 3436, 2920, 2924, 2925, 2927, 2928, 2929, 2931, 2940, 2943, 2944, 2945, 2948, 2953, 2956, 2960, 2963, 2966, 2967, 2969, 2974, 2977, 2978, 2981, 2985, 2986, 2987, 2988, 2993, 2994, 3000, 3004, 3010, 3014, 3022, 3023, 3025, 3026, 3029, 3030, 3033, 3036, 3040, 3042, 3044, 3045, 3047, 3052, 3054, 3056, 3059, 3064, 3065}), frozenset({2560, 2561, 2563, 2564, 2055, 2056, 2059, 2060, 2573, 2574, 2575, 2063, 2064, 2578, 2579, 2069, 2040, 2073, 2586, 2074, 2077, 2590, 2591, 2078, 2593, 2083, 2084, 2086, 2043, 2600, 2601, 2602, 2088, 2604, 2090, 2606, 2095, 2607, 2093, 2098, 2611, 2613, 2103, 2104, 2615, 2619, 2108, 2109, 2623, 2112, 2624, 2625, 2115, 2118, 2630, 2631, 2121, 2122, 2123, 2124, 2638, 2131, 2646, 2136, 2139, 2140, 2142, 2654, 2655, 2150, 2154, 2164, 2165, 2172, 2179, 2184, 2188, 2190, 2200, 2201, 2206, 2210, 2212, 2213, 2216, 2218, 2220, 2229, 2233, 2237, 2240, 2244, 2253, 2257, 2258, 2261, 2266, 2271, 2275, 2276, 2278, 2287, 2290, 2299, 2300, 2306, 2307, 2308, 2309, 2311, 2323, 2324, 2326, 2329, 2331, 2334, 2339, 2340, 2348, 2352, 2353, 2354, 2356, 2359, 2363, 2369, 2370, 2374, 2376, 2381, 2386, 2392, 2395, 2404, 2407, 2408, 2409, 2410, 2414, 2418, 2423, 2428, 1917, 2430, 1918, 2433, 1925, 1929, 2442, 2446, 1938, 1943, 1946, 2460, 2462, 2464, 1953, 2467, 2469, 1962, 1963, 2477, 1966, 2482, 1971, 2484, 2485, 2489, 1979, 2492, 2495, 1983, 1984, 1985, 2499, 2500, 1986, 1989, 2504, 1993, 2506, 2507, 1997, 2005, 2520, 2521, 2524, 2526, 2532, 2020, 2021, 2536, 2539, 2542, 2030, 2033, 2546, 2549, 2550, 2551, 2552, 2553, 2554, 2037, 2556, 2045, 2046, 2559}), frozenset({686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 795, 796, 797, 798, 799, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, 844, 845, 846, 847, 848, 849, 850, 851, 852, 853, 854, 855, 856, 858, 859, 860, 861, 863, 864, 866, 867, 869, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895}), frozenset({3980, 3981, 3982, 3983, 3984, 3985, 3986, 3987, 3988, 3989, 3990, 3991, 3992, 3993, 3994, 3995, 3996, 3997, 3998, 3999, 4000, 4001, 4002, 4003, 4004, 4005, 4006, 4007, 4008, 4009, 4010, 4011, 4012, 4013, 4014, 4015, 4016, 4017, 4018, 4019, 4020, 4021, 4022, 4023, 4024, 4025, 4026, 4027, 4028, 4029, 4030, 4031, 4032, 4033, 4034, 4035, 4036, 4037, 4038}), frozenset({901, 1798, 903, 1802, 1548, 1424, 1568, 1186, 1314, 1319, 938, 1452, 1837, 1333, 1468, 958, 1216, 1601, 963, 1733, 1097, 1232, 1747, 1363, 1493, 1880, 1629, 1118, 992, 1378, 1892, 1895, 1648, 1137, 1784, 1787, 1533}), frozenset({640, 643, 647, 650, 658, 659, 661, 662, 665, 670, 675, 681, 576, 577, 578, 582, 583, 595, 599, 600, 615, 627, 628, 632, 635}), frozenset({3008, 2982, 3423, 2699, 3309, 2670, 3311, 2959, 2767, 3314, 2834, 2703, 3283, 3382, 3318, 2972, 3325, 2879}), frozenset({2817, 3074, 3147, 3055, 2774, 3127})]
In [48]:
print("Modularity:", nx.algorithms.community.modularity(G_fbsocial, greed_list_fb))
Modularity: 0.7773775199039185
In [49]:
plot_community_subgraph(G_fbsocial, greed_list_fb)

Community detection on G_subgraph_fb

G_subgraph_fb Girvan newman
In [ ]:
graph_subfb, modularity_subfb, community_node_groups_subfb = community_node(G_subgraph_fb, 5)
In [55]:
modularity_subfb
Out[55]:
[0.00285275007096373,
 0.24946820707882778,
 0.23153836445572948,
 0.11348171106943142,
 0.0044912808798421395]
In [56]:
print("Modularity:", nx.algorithms.community.modularity(G_subgraph_fb, community_node_groups_subfb))
Modularity: 0.6019456060093185
In [57]:
plot_community_subgraph(G_subgraph_fb, community_node_groups_subfb)
G_subgraph_fb Greedy modularity
In [58]:
greed_community_subfb = greedy_modularity_communities(G_subgraph_fb)
greed_list_subfb = list(greed_community_subfb)
print("number of communities is", len(list(greed_community_subfb)))
print(greed_list_subfb)
number of communities is 8
[frozenset({1024, 1026, 1538, 1028, 1029, 1539, 1542, 1547, 1551, 1040, 1554, 1557, 1047, 1048, 1049, 1559, 1563, 1054, 1056, 1570, 1059, 1571, 1580, 1584, 1074, 1075, 1076, 1589, 1078, 1079, 1590, 1083, 1597, 1598, 1600, 1603, 1604, 1605, 1608, 1609, 1610, 1612, 1101, 1613, 1614, 1617, 1107, 1619, 1620, 1110, 1621, 1112, 1622, 1623, 1117, 1632, 1123, 1124, 1125, 1126, 1637, 1128, 1639, 1130, 1643, 1132, 1644, 1135, 1652, 1653, 1146, 1659, 1149, 1662, 1663, 1153, 1665, 1156, 1668, 1669, 1160, 1163, 1675, 1683, 1172, 1173, 1685, 1175, 1688, 1689, 1181, 1182, 1184, 1185, 1191, 1707, 1198, 1199, 1712, 1201, 1714, 1205, 1717, 1207, 1209, 1721, 1211, 1722, 1724, 1214, 1730, 1219, 1222, 1735, 1736, 1737, 1741, 1230, 1746, 1238, 1750, 1752, 1753, 1242, 1243, 1754, 1757, 1761, 1250, 1765, 1255, 1256, 1768, 1772, 1267, 1269, 1782, 1271, 1272, 1789, 1791, 1280, 1793, 1795, 1796, 1285, 1799, 1800, 1287, 1288, 1289, 1804, 1290, 1291, 1809, 1810, 1811, 1813, 1302, 1816, 1305, 1819, 1823, 1312, 1826, 1827, 1833, 1835, 1323, 1839, 1329, 1842, 1330, 1331, 1845, 1335, 1336, 1849, 1339, 1340, 1341, 1344, 1861, 1351, 1864, 1352, 1867, 1868, 1359, 1361, 1877, 1879, 1367, 1369, 1370, 1886, 1375, 1888, 1376, 1377, 1891, 1380, 1898, 1388, 1902, 1390, 1391, 1393, 1399, 1402, 897, 1409, 1416, 906, 1420, 916, 1431, 921, 925, 1437, 927, 932, 934, 1447, 1449, 1456, 1457, 946, 947, 952, 953, 1467, 1470, 1471, 960, 966, 967, 1480, 1483, 1488, 978, 1491, 980, 982, 983, 993, 995, 997, 1509, 999, 1513, 1003, 1004, 1516, 1006, 1520, 1522, 1523, 1528, 1017, 1530, 1535}), frozenset({2560, 2561, 2563, 2564, 2055, 2056, 2058, 2059, 2060, 2573, 2574, 2063, 2064, 2575, 2578, 2579, 2069, 2073, 2074, 2586, 2077, 2078, 2590, 2591, 2593, 2083, 2084, 2551, 2086, 2088, 2552, 2090, 2600, 2601, 2093, 2602, 2095, 2604, 2606, 2098, 2607, 2611, 2103, 2104, 2615, 2619, 2108, 2109, 2623, 2112, 2624, 2625, 2115, 2118, 2630, 2631, 2121, 2122, 2123, 2124, 2638, 2131, 2646, 2136, 2139, 2140, 2142, 2654, 2655, 2150, 2154, 2164, 2165, 2172, 2179, 2184, 2188, 2190, 2200, 2201, 2206, 2210, 2212, 2213, 2216, 2218, 2220, 2229, 2233, 2237, 2240, 2244, 2253, 2257, 2261, 2266, 2271, 2275, 2276, 2278, 2287, 2290, 2299, 2300, 2306, 2307, 2308, 2309, 2311, 2323, 2324, 2326, 2329, 2331, 2334, 2339, 2340, 2348, 2352, 2353, 2354, 2356, 2359, 2363, 2369, 2370, 2374, 2376, 2381, 2386, 2391, 2392, 2395, 2404, 2407, 2408, 2409, 2410, 2414, 2418, 2423, 2428, 1917, 1918, 2429, 2430, 2433, 1925, 1929, 2446, 1938, 1943, 1946, 2460, 2462, 2464, 1953, 2467, 2469, 1962, 1963, 2477, 1966, 2478, 2482, 1971, 2484, 2485, 2489, 1979, 2492, 1983, 1984, 1985, 1986, 2495, 2499, 1989, 2500, 2504, 1993, 2506, 2507, 1997, 2005, 2520, 2521, 2526, 2020, 2532, 2536, 2539, 2030, 2542, 2033, 2546, 2037, 2549, 2550, 2040, 2553, 2554, 2043, 2556, 2045, 2046, 2559}), frozenset({2052, 2053, 2054, 2567, 2062, 2068, 2582, 2071, 2072, 2588, 2589, 2592, 2081, 2594, 2597, 2598, 2087, 1577, 2603, 2608, 2610, 2101, 2102, 2616, 2617, 2620, 2111, 2116, 2117, 2629, 2125, 2126, 2127, 2128, 2640, 2642, 2643, 2132, 2133, 2134, 2135, 2645, 2649, 2138, 2653, 2143, 2144, 2657, 2659, 2148, 2149, 2151, 2153, 2161, 2169, 2171, 2174, 2176, 2180, 2183, 136, 2187, 2189, 2191, 2194, 2196, 2198, 2199, 2203, 2211, 2215, 2223, 2224, 2226, 1718, 2232, 2235, 2241, 2243, 2246, 2247, 2250, 2254, 2259, 2264, 2267, 2268, 2273, 2279, 2280, 2282, 2283, 2284, 2285, 2289, 2292, 2293, 2294, 2302, 2304, 2313, 2315, 2319, 2325, 2327, 2328, 2332, 2333, 2336, 2338, 2343, 2344, 2345, 2347, 2351, 2364, 2365, 2368, 2372, 2377, 2384, 2385, 2394, 2396, 2398, 2399, 2417, 2419, 2420, 1912, 1916, 1919, 1920, 2434, 1923, 2436, 1926, 1927, 2438, 1932, 2445, 1939, 1940, 1941, 2451, 1945, 2458, 1947, 1948, 2461, 1951, 2463, 2465, 1954, 1955, 2468, 2471, 2472, 1959, 2475, 1964, 1970, 1972, 1973, 1465, 2491, 1980, 1981, 2498, 2501, 1994, 1995, 2508, 2509, 1998, 2510, 2511, 2001, 2002, 2512, 2516, 2006, 2007, 2010, 2018, 2533, 2024, 2537, 2026, 2538, 2028, 2031, 2032, 2543, 2547, 2038, 2039, 2042, 2555, 2047}), frozenset({1536, 513, 514, 515, 1540, 517, 1032, 1036, 524, 525, 526, 538, 1052, 542, 544, 1060, 1573, 1574, 1576, 553, 1066, 1067, 1070, 559, 1583, 561, 563, 1587, 566, 567, 1080, 1591, 1082, 1596, 1086, 580, 1099, 1100, 1611, 1102, 1104, 1628, 606, 1630, 1120, 1636, 1129, 107, 1645, 1655, 1148, 637, 1661, 641, 1158, 1159, 651, 1166, 1680, 1691, 1703, 1192, 1709, 1715, 1204, 1716, 1725, 1729, 1221, 1227, 1742, 1231, 1235, 1237, 1257, 1261, 1783, 1273, 1786, 1275, 1277, 1282, 1794, 1284, 1292, 1807, 1298, 1820, 1824, 1828, 1320, 1322, 1844, 1334, 1338, 1857, 1345, 1347, 1862, 1358, 1871, 1876, 1366, 1881, 1882, 348, 1373, 353, 1379, 1893, 1894, 1899, 363, 366, 370, 1396, 373, 374, 376, 378, 896, 1413, 391, 395, 1423, 400, 402, 1426, 404, 917, 1427, 408, 1432, 1435, 412, 414, 417, 930, 419, 422, 423, 1448, 428, 941, 942, 431, 432, 1454, 1459, 436, 438, 1462, 954, 957, 1469, 1472, 1473, 1475, 1479, 456, 460, 461, 975, 1487, 465, 507, 1495, 475, 1502, 1504, 483, 484, 1515, 492, 493, 1009, 497, 506, 500, 1525, 1014, 503, 1018, 1019, 1020, 1021}), frozenset({3076, 3077, 3082, 3087, 3089, 3101, 3106, 3107, 3111, 3113, 3115, 3116, 3117, 3120, 3132, 3136, 3140, 3145, 3146, 3150, 3152, 3154, 3162, 3169, 3172, 2661, 3179, 3182, 3185, 2674, 3188, 3198, 3201, 3206, 3214, 1684, 3224, 2716, 2719, 3233, 2724, 3239, 3240, 2730, 3247, 3252, 3253, 2742, 3256, 2748, 3261, 3263, 2753, 3267, 3274, 3277, 3280, 2778, 3291, 2780, 2781, 3297, 3299, 3302, 2793, 2796, 3320, 3321, 3330, 3332, 3335, 2828, 3342, 3344, 3345, 2833, 3347, 3350, 3351, 3353, 3355, 3360, 2849, 2853, 3366, 2863, 3378, 3381, 2869, 3385, 3386, 2875, 3391, 3396, 3397, 3403, 3406, 2894, 3411, 2901, 3416, 2904, 3419, 3434, 2936, 2937, 2939, 2946, 2951, 2973, 2989, 2991, 2992, 3002, 3017, 3019, 3027, 3035, 3038, 1505, 3049, 3051, 3060, 3070}), frozenset({3073, 3078, 3084, 3085, 3090, 3096, 3098, 3104, 3108, 3119, 3142, 3149, 3158, 3174, 2664, 2666, 2669, 3184, 2676, 2679, 2680, 3195, 2683, 2689, 2694, 2698, 2706, 3220, 3226, 2717, 3232, 2729, 2738, 2741, 2743, 2749, 2750, 2754, 2755, 2757, 2763, 3284, 2773, 2777, 3293, 2782, 2786, 2800, 2810, 3324, 2815, 3339, 2827, 3348, 2839, 3362, 3363, 2862, 2864, 2866, 2867, 2872, 2873, 3387, 2877, 2880, 2890, 2897, 3417, 2905, 2906, 2909, 2910, 2911, 2912, 2913, 3426, 2915, 2916, 2919, 2920, 3433, 2925, 2927, 2928, 2931, 2940, 2943, 2944, 2945, 2956, 2960, 2966, 2969, 2974, 2985, 2986, 2988, 2993, 2994, 3000, 3004, 3022, 3025, 3026, 3029, 3033, 3040, 3054, 3056, 3064, 3065}), frozenset({3456, 3851, 3596, 781, 3604, 3611, 3877, 805, 3495, 3756, 686, 3633, 694, 823, 824, 697, 698, 828, 1085, 830, 705, 3521, 713, 719, 3545, 3938, 3684, 745, 747, 3948, 3437, 3830, 3577, 3838}), frozenset({0, 322, 26, 67, 200, 9, 203, 239, 304, 271, 21, 277, 119, 56, 25, 122, 315, 252})]
In [59]:
print("Modularity:", nx.algorithms.community.modularity(G_subgraph_fb, greed_list_subfb))
Modularity: 0.7364018612692158
In [60]:
plot_community_subgraph(G_subgraph_fb, greed_list_subfb)

Community detection based on user '1912'

Let's create a subgraph based on the actor '1912'
In [61]:
subgraph_1912 = create_subgraph(G_fbsocial, 1912)
In [64]:
print(nx.info(subgraph_1912))
Name: 
Type: Graph
Number of nodes: 1003
Number of edges: 33999
Average degree:  67.7946
In [65]:
plot_subgraph(subgraph_1912, 1912)
Subgraph_1912 Girvan newman
In [52]:
graph_1912, modularity_1912, community_node_groups_1912 = community_node(subgraph_1912, 5)
In [62]:
modularity_1912
Out[62]:
[0.0831395407920629,
 0.0006769083994099884,
 0.06833640749522235,
 0.0029895525271120297,
 0.011653182721168016]
In [63]:
print("Modularity:", nx.algorithms.community.modularity(subgraph_1912, community_node_groups_1912))
Modularity: 0.16735215032772868
In [66]:
plt_network(graph_1912)
In [67]:
plot_community_subgraph(subgraph_1912, community_node_groups_1912)
Subgraph_1912 Greedy modularity
In [68]:
greed_community_1912 = greedy_modularity_communities(subgraph_1912)
greed_list_1912 = list(greed_community_1912)
print("number of communities is", len(list(greed_community_1912)))
print(greed_list_1912)
number of communities is 5
[frozenset({2048, 2052, 2053, 2054, 2057, 2062, 2065, 2066, 2068, 2071, 2072, 2075, 2076, 2079, 2081, 2085, 2087, 2096, 2099, 2101, 2102, 2110, 2111, 2117, 2125, 2127, 2128, 2132, 2133, 2134, 2135, 2137, 2138, 2141, 2143, 2144, 2145, 2148, 2149, 2151, 2153, 2155, 2161, 2163, 2169, 2170, 2174, 2175, 2176, 2177, 2180, 2182, 2183, 136, 2185, 2186, 2187, 2189, 2191, 2194, 2195, 2196, 2198, 2199, 2203, 2205, 2207, 2208, 2209, 2211, 2214, 2215, 2219, 2221, 2222, 2223, 2224, 2226, 2230, 2232, 2235, 2239, 2241, 2242, 2243, 2246, 2247, 2249, 2250, 2252, 2254, 2255, 2256, 2259, 2264, 2265, 2267, 2268, 2269, 2270, 2272, 2273, 2274, 2279, 2280, 2282, 2283, 2285, 2289, 2291, 2292, 2293, 2294, 2295, 2296, 2298, 2302, 2304, 2305, 2310, 2312, 2315, 2318, 2319, 2320, 2322, 2325, 2327, 2328, 2330, 2332, 2333, 2336, 2338, 2343, 2344, 2345, 2347, 2349, 2351, 2355, 2358, 2362, 2366, 2367, 2368, 2372, 2377, 2379, 2384, 2385, 2389, 2390, 2394, 2396, 2398, 2399, 2400, 2401, 2406, 2413, 2415, 2416, 2417, 2419, 2420, 2425, 2426, 2432, 2434, 2436, 2438, 2443, 2444, 2445, 2451, 2452, 2453, 2457, 2458, 2461, 2463, 2465, 2466, 2470, 2471, 2472, 2473, 2475, 2479, 2480, 2483, 2486, 2490, 2491, 2493, 2496, 2498, 2501, 2502, 2505, 2508, 2509, 2510, 2511, 2512, 2513, 2514, 2515, 2516, 2517, 2518, 2519, 2522, 2525, 2527, 2529, 2530, 2531, 2533, 2537, 2540, 2543, 2544, 2547, 2555, 2557, 2566, 2567, 2568, 2569, 2571, 2572, 2581, 2582, 2588, 2589, 2592, 2594, 2595, 2596, 2597, 2598, 2599, 2603, 2605, 2608, 2609, 2610, 2612, 2616, 2617, 2622, 2629, 2635, 2637, 2641, 2642, 2643, 2649, 2650, 2651, 2652, 2653, 1465, 1577, 1718, 1912, 1913, 1916, 1920, 1923, 1924, 1926, 1932, 1939, 1940, 1941, 1944, 1945, 1947, 1948, 1952, 1954, 1955, 1959, 1964, 1965, 1969, 1970, 1974, 1977, 1981, 1982, 1987, 1988, 1992, 1994, 2002, 2003, 2007, 2010, 2026, 2028, 2029, 2031, 2032, 2036, 2038, 2039, 2042, 2047}), frozenset({0, 513, 514, 515, 516, 517, 518, 7, 520, 512, 1028, 523, 524, 525, 526, 1545, 528, 1549, 531, 21, 534, 541, 542, 543, 544, 545, 546, 34, 549, 1534, 1574, 553, 554, 556, 558, 559, 1070, 561, 1074, 563, 1536, 1077, 566, 567, 56, 569, 58, 570, 1029, 1590, 67, 1540, 591, 1617, 594, 1618, 1109, 1621, 87, 601, 1114, 1626, 604, 606, 609, 3173, 614, 103, 1126, 107, 1136, 120, 634, 122, 125, 1663, 641, 1666, 645, 651, 1165, 146, 1171, 1684, 1173, 1687, 1688, 667, 156, 669, 1179, 1182, 1692, 1697, 676, 1702, 169, 1967, 683, 171, 1196, 1197, 1210, 1217, 1226, 1740, 1745, 213, 1237, 3290, 1769, 1777, 1778, 1780, 246, 1782, 2814, 1289, 269, 1808, 1300, 2838, 1817, 285, 1312, 1313, 1320, 1835, 1836, 1327, 304, 308, 1334, 1846, 1338, 315, 1852, 322, 324, 2885, 1863, 1352, 1358, 1361, 339, 1369, 1883, 348, 1374, 350, 1376, 353, 357, 360, 366, 369, 370, 373, 374, 1909, 376, 1911, 378, 1408, 387, 391, 392, 395, 908, 397, 400, 1425, 402, 915, 916, 404, 405, 407, 408, 921, 412, 925, 414, 415, 416, 417, 930, 1440, 419, 420, 1446, 423, 421, 425, 426, 427, 428, 430, 431, 432, 433, 434, 435, 436, 1458, 438, 439, 951, 442, 3003, 444, 449, 962, 451, 452, 455, 456, 457, 459, 460, 461, 1483, 463, 1485, 465, 469, 471, 473, 475, 477, 479, 480, 482, 483, 484, 1509, 485, 1512, 1513, 492, 497, 1522, 1523, 500, 1013, 504, 506, 507, 508, 510, 511}), frozenset({2560, 2561, 2563, 2564, 2055, 2056, 2058, 2059, 2060, 2573, 2574, 2063, 2064, 2575, 2576, 2067, 2578, 2069, 2579, 2584, 2073, 2074, 2586, 2077, 2078, 2590, 2591, 2593, 2083, 2084, 2551, 2086, 2088, 2600, 2090, 2601, 2092, 2093, 2602, 2095, 2606, 2604, 2607, 2098, 2611, 2613, 2103, 2104, 2615, 2619, 2108, 2109, 2556, 2623, 2112, 2624, 2625, 2115, 2118, 2630, 2631, 2121, 2122, 2123, 2124, 2638, 2131, 2646, 2136, 2139, 2140, 2142, 2654, 2655, 2147, 2150, 2154, 2164, 2165, 2172, 2179, 2184, 2188, 2190, 2200, 2201, 2206, 2210, 2212, 2213, 2216, 2218, 2220, 2229, 2233, 2234, 2237, 2240, 2244, 2552, 2253, 2257, 2258, 2261, 2262, 2266, 2271, 2275, 2276, 2278, 2287, 2288, 2290, 2299, 2300, 2303, 2306, 2307, 2308, 2309, 2311, 2323, 2324, 2326, 2329, 2331, 2334, 2339, 2340, 2348, 2350, 2352, 2353, 2354, 2356, 2359, 2363, 2369, 2370, 2374, 2376, 2381, 2383, 2386, 2387, 2391, 2392, 2393, 2395, 2404, 2407, 2408, 2409, 2410, 2414, 2418, 2423, 2427, 2428, 1917, 1918, 2429, 2430, 2433, 1925, 1929, 2442, 2446, 2449, 1938, 1942, 1943, 2454, 1946, 2460, 2462, 2464, 1953, 2467, 2468, 2469, 1962, 1963, 2476, 2477, 1966, 2478, 2482, 1971, 2484, 2485, 2489, 1979, 2492, 1983, 1984, 1985, 1986, 2495, 2499, 1989, 2500, 2504, 1993, 2506, 2507, 1997, 2005, 2520, 2521, 2524, 2526, 2019, 2020, 2021, 2532, 2536, 2539, 2030, 2542, 2033, 2545, 2546, 2037, 2549, 2550, 2040, 2553, 2554, 2043, 2044, 2045, 2046, 2559}), frozenset({2049, 2562, 2051, 2565, 2570, 2577, 2580, 2070, 2587, 2080, 2082, 2089, 2091, 2094, 2100, 2614, 2105, 2106, 2107, 2618, 2621, 2113, 2114, 2628, 2119, 2120, 2632, 2634, 2126, 2129, 2130, 2644, 2656, 2146, 2659, 2152, 2156, 2158, 2160, 2162, 2166, 2167, 2168, 2173, 2178, 2181, 2193, 2197, 2204, 2217, 2227, 2228, 2231, 2236, 2238, 2245, 2248, 2251, 2260, 2263, 2277, 2281, 2286, 2301, 2313, 2314, 2316, 2317, 2321, 2335, 2341, 2342, 2357, 2360, 2361, 2371, 2373, 2375, 2380, 2382, 2388, 2397, 2402, 2403, 2405, 2411, 2412, 2421, 2422, 2424, 1915, 2431, 1922, 2437, 2439, 2440, 2441, 1930, 1933, 1934, 1936, 1937, 2448, 2450, 2455, 2456, 1949, 1956, 1960, 1961, 2474, 2481, 1975, 2487, 2488, 1978, 2497, 1990, 2503, 1996, 2008, 2523, 2015, 2528, 2017, 2534, 2023, 2535, 2541, 2034, 2035, 2548, 2041, 2558}), frozenset({1921, 2050, 2435, 1927, 1928, 1931, 2061, 1935, 2447, 2192, 2583, 2585, 2202, 2459, 1950, 1951, 2337, 1957, 1958, 2346, 1968, 2097, 2225, 1972, 1973, 1976, 2364, 2365, 2620, 1980, 2494, 2626, 2627, 2116, 1991, 2633, 2378, 1995, 2636, 1998, 2639, 2640, 1999, 2000, 2001, 2004, 2645, 2006, 2647, 2648, 2009, 2011, 2012, 2013, 2014, 2016, 2657, 2658, 2018, 2660, 2022, 2024, 2025, 2538, 2027, 2284, 2157, 2159, 2297, 1914, 2171, 1919})]
In [69]:
print("Modularity:", nx.algorithms.community.modularity(subgraph_1912, greed_list_1912))
Modularity: 0.5855381453359202
In [70]:
plot_community_subgraph(subgraph_1912, greed_list_1912)

Community detection based on user '107'

Let's create a subgraph based on the actor '107'
In [71]:
subgraph_107 = create_subgraph(G_fbsocial, 107)
In [72]:
print(nx.info(subgraph_107))
Name: 
Type: Graph
Number of nodes: 2687
Number of edges: 58061
Average degree:  43.2162
In [73]:
plot_subgraph(subgraph_107, 107)
Graph 107 Girvan newman
In [76]:
graph_107, modularity_107, community_node_groups_107 = community_node(subgraph_107, 2)
In [90]:
modularity_107
Out[90]:
[0.046162324723618385, 0.04518099614085494]
In [91]:
print("Modularity:", nx.algorithms.community.modularity(subgraph_107, community_node_groups_107))
Modularity: 0.09232464944694044
In [92]:
print(community_node_groups_107)
[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 167, 168, 169, 170, 172, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 199, 200, 201, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347], [34, 58, 107, 136, 166, 171, 173, 198, 202, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 860, 862, 896, 897, 898, 899, 900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124, 1125, 1126, 1127, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1138, 1139, 1140, 1141, 1142, 1143, 1144, 1145, 1146, 1147, 1148, 1149, 1150, 1151, 1152, 1153, 1154, 1155, 1156, 1157, 1158, 1159, 1160, 1161, 1162, 1163, 1164, 1165, 1166, 1167, 1168, 1169, 1170, 1171, 1172, 1173, 1174, 1175, 1176, 1177, 1178, 1179, 1180, 1181, 1182, 1183, 1184, 1185, 1186, 1187, 1188, 1189, 1190, 1191, 1192, 1193, 1194, 1195, 1196, 1197, 1198, 1199, 1200, 1201, 1202, 1203, 1204, 1205, 1206, 1207, 1208, 1209, 1210, 1211, 1212, 1213, 1214, 1215, 1216, 1217, 1218, 1219, 1220, 1221, 1222, 1223, 1224, 1225, 1226, 1227, 1228, 1229, 1230, 1231, 1232, 1233, 1234, 1235, 1236, 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244, 1245, 1246, 1247, 1248, 1249, 1250, 1251, 1252, 1253, 1254, 1255, 1256, 1257, 1258, 1259, 1260, 1261, 1262, 1263, 1264, 1265, 1266, 1267, 1268, 1269, 1270, 1271, 1272, 1273, 1274, 1275, 1276, 1277, 1278, 1279, 1280, 1281, 1282, 1283, 1284, 1285, 1286, 1287, 1288, 1289, 1290, 1291, 1292, 1293, 1294, 1295, 1296, 1297, 1298, 1299, 1300, 1301, 1302, 1303, 1304, 1305, 1306, 1307, 1308, 1309, 1310, 1311, 1312, 1313, 1314, 1315, 1316, 1317, 1318, 1319, 1320, 1321, 1322, 1323, 1324, 1325, 1326, 1327, 1328, 1329, 1330, 1331, 1332, 1333, 1334, 1335, 1336, 1337, 1338, 1339, 1340, 1341, 1342, 1343, 1344, 1345, 1346, 1347, 1348, 1349, 1350, 1351, 1352, 1353, 1354, 1355, 1356, 1357, 1358, 1359, 1360, 1361, 1362, 1363, 1364, 1365, 1366, 1367, 1368, 1369, 1370, 1371, 1372, 1373, 1374, 1375, 1376, 1377, 1378, 1379, 1380, 1381, 1382, 1383, 1384, 1385, 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399, 1400, 1401, 1402, 1403, 1404, 1405, 1406, 1407, 1408, 1409, 1410, 1411, 1412, 1413, 1414, 1415, 1416, 1417, 1418, 1419, 1420, 1421, 1422, 1423, 1424, 1425, 1426, 1427, 1428, 1429, 1430, 1431, 1432, 1433, 1434, 1435, 1436, 1437, 1438, 1439, 1440, 1441, 1442, 1443, 1444, 1445, 1446, 1447, 1448, 1449, 1450, 1451, 1452, 1453, 1454, 1455, 1456, 1457, 1458, 1459, 1460, 1461, 1462, 1463, 1464, 1465, 1466, 1467, 1468, 1469, 1470, 1471, 1472, 1473, 1474, 1475, 1476, 1477, 1478, 1479, 1480, 1481, 1482, 1483, 1484, 1485, 1486, 1487, 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496, 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, 1515, 1516, 1517, 1518, 1519, 1520, 1521, 1522, 1523, 1524, 1525, 1526, 1527, 1528, 1529, 1530, 1531, 1532, 1533, 1534, 1535, 1536, 1537, 1538, 1539, 1540, 1541, 1542, 1543, 1544, 1545, 1546, 1547, 1548, 1549, 1550, 1551, 1552, 1553, 1554, 1555, 1556, 1557, 1558, 1559, 1560, 1561, 1562, 1563, 1564, 1565, 1566, 1567, 1568, 1569, 1570, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1578, 1579, 1580, 1581, 1582, 1583, 1584, 1585, 1586, 1587, 1588, 1589, 1590, 1591, 1592, 1593, 1594, 1595, 1596, 1597, 1598, 1599, 1600, 1601, 1602, 1603, 1604, 1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613, 1614, 1615, 1616, 1617, 1618, 1619, 1620, 1621, 1622, 1623, 1624, 1625, 1626, 1627, 1628, 1629, 1630, 1631, 1632, 1633, 1634, 1635, 1636, 1637, 1638, 1639, 1640, 1641, 1642, 1643, 1644, 1645, 1646, 1647, 1648, 1649, 1650, 1651, 1652, 1653, 1654, 1655, 1656, 1657, 1658, 1659, 1660, 1661, 1662, 1663, 1664, 1665, 1666, 1667, 1668, 1669, 1670, 1671, 1672, 1673, 1674, 1675, 1676, 1677, 1678, 1679, 1680, 1681, 1682, 1683, 1684, 1685, 1686, 1687, 1688, 1689, 1690, 1691, 1692, 1693, 1694, 1695, 1696, 1697, 1698, 1699, 1700, 1701, 1702, 1703, 1704, 1705, 1706, 1707, 1708, 1709, 1710, 1711, 1712, 1713, 1714, 1715, 1716, 1717, 1718, 1719, 1720, 1721, 1722, 1723, 1724, 1725, 1726, 1727, 1728, 1729, 1730, 1731, 1732, 1733, 1734, 1735, 1736, 1737, 1738, 1739, 1740, 1741, 1742, 1743, 1744, 1745, 1746, 1747, 1748, 1749, 1750, 1751, 1752, 1753, 1754, 1755, 1756, 1757, 1758, 1759, 1760, 1761, 1762, 1763, 1764, 1765, 1766, 1767, 1768, 1769, 1770, 1771, 1772, 1773, 1774, 1775, 1776, 1777, 1778, 1779, 1780, 1781, 1782, 1783, 1784, 1785, 1786, 1787, 1788, 1789, 1790, 1791, 1792, 1793, 1794, 1795, 1796, 1797, 1798, 1799, 1800, 1801, 1802, 1803, 1804, 1805, 1806, 1807, 1808, 1809, 1810, 1811, 1812, 1813, 1814, 1815, 1816, 1817, 1818, 1819, 1820, 1821, 1822, 1823, 1824, 1825, 1826, 1827, 1828, 1829, 1830, 1831, 1832, 1833, 1834, 1835, 1836, 1837, 1838, 1839, 1840, 1841, 1842, 1843, 1844, 1845, 1846, 1847, 1848, 1849, 1850, 1851, 1852, 1853, 1854, 1855, 1856, 1857, 1858, 1859, 1860, 1861, 1862, 1863, 1864, 1865, 1866, 1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874, 1875, 1876, 1877, 1878, 1879, 1880, 1881, 1882, 1883, 1884, 1885, 1886, 1887, 1888, 1889, 1890, 1891, 1892, 1893, 1894, 1895, 1896, 1897, 1898, 1899, 1900, 1901, 1902, 1903, 1904, 1905, 1906, 1907, 1908, 1909, 1910, 1911, 1912, 1913, 1916, 1920, 1926, 1932, 1940, 1941, 1945, 1947, 1948, 1954, 1955, 1959, 1967, 1994, 2002, 2003, 2007, 2010, 2026, 2028, 2031, 2032, 2038, 2039, 2042, 2047, 2052, 2053, 2054, 2062, 2065, 2068, 2071, 2072, 2081, 2087, 2101, 2102, 2111, 2117, 2125, 2127, 2128, 2132, 2133, 2134, 2135, 2137, 2138, 2143, 2144, 2148, 2149, 2151, 2153, 2155, 2163, 2169, 2174, 2176, 2180, 2183, 2185, 2187, 2189, 2191, 2194, 2196, 2198, 2199, 2203, 2215, 2223, 2224, 2239, 2241, 2246, 2247, 2250, 2254, 2264, 2266, 2267, 2268, 2273, 2279, 2282, 2283, 2285, 2289, 2292, 2293, 2294, 2295, 2298, 2302, 2315, 2319, 2325, 2327, 2328, 2330, 2332, 2333, 2336, 2338, 2343, 2344, 2347, 2351, 2355, 2368, 2372, 2377, 2384, 2385, 2389, 2394, 2398, 2399, 2413, 2417, 2419, 2420, 2436, 2445, 2451, 2458, 2461, 2463, 2465, 2468, 2471, 2472, 2475, 2491, 2496, 2498, 2501, 2502, 2508, 2509, 2510, 2511, 2512, 2516, 2519, 2529, 2530, 2533, 2542, 2543, 2544, 2547, 2555, 2567, 2582, 2588, 2589, 2592, 2594, 2597, 2598, 2605, 2608, 2609, 2616, 2617, 2629, 2642, 2643, 2649, 2653, 2661, 2662, 2663, 2664, 2665, 2666, 2667, 2668, 2669, 2670, 2671, 2672, 2673, 2674, 2675, 2676, 2677, 2678, 2679, 2680, 2681, 2682, 2683, 2684, 2685, 2686, 2687, 2688, 2689, 2690, 2691, 2692, 2693, 2694, 2695, 2696, 2697, 2698, 2699, 2700, 2701, 2702, 2703, 2704, 2705, 2706, 2707, 2708, 2709, 2710, 2711, 2712, 2713, 2714, 2715, 2716, 2717, 2718, 2719, 2720, 2721, 2722, 2723, 2724, 2725, 2726, 2727, 2728, 2729, 2730, 2731, 2732, 2733, 2734, 2735, 2736, 2737, 2738, 2739, 2740, 2741, 2742, 2743, 2744, 2745, 2746, 2747, 2748, 2749, 2750, 2751, 2752, 2753, 2754, 2755, 2756, 2757, 2758, 2759, 2760, 2761, 2762, 2763, 2764, 2765, 2766, 2767, 2768, 2769, 2770, 2771, 2772, 2773, 2774, 2775, 2776, 2777, 2778, 2779, 2780, 2781, 2782, 2783, 2784, 2785, 2786, 2787, 2788, 2789, 2790, 2791, 2792, 2793, 2794, 2795, 2796, 2797, 2798, 2799, 2800, 2801, 2802, 2803, 2804, 2805, 2806, 2807, 2808, 2809, 2810, 2811, 2812, 2813, 2814, 2815, 2816, 2817, 2818, 2819, 2820, 2821, 2822, 2823, 2824, 2825, 2826, 2827, 2828, 2829, 2830, 2831, 2832, 2833, 2834, 2835, 2836, 2837, 2838, 2839, 2840, 2841, 2842, 2843, 2844, 2845, 2846, 2847, 2848, 2849, 2850, 2851, 2852, 2853, 2854, 2855, 2856, 2857, 2858, 2859, 2860, 2861, 2862, 2863, 2864, 2865, 2866, 2867, 2868, 2869, 2870, 2871, 2872, 2873, 2874, 2875, 2876, 2877, 2878, 2879, 2880, 2881, 2882, 2883, 2884, 2885, 2886, 2887, 2888, 2889, 2890, 2891, 2892, 2893, 2894, 2895, 2896, 2897, 2898, 2899, 2900, 2901, 2902, 2903, 2904, 2905, 2906, 2907, 2908, 2909, 2910, 2911, 2912, 2913, 2914, 2915, 2916, 2917, 2918, 2919, 2920, 2921, 2922, 2923, 2924, 2925, 2926, 2927, 2928, 2929, 2930, 2931, 2932, 2933, 2934, 2935, 2936, 2937, 2938, 2939, 2940, 2941, 2942, 2943, 2944, 2945, 2946, 2947, 2948, 2949, 2950, 2951, 2952, 2953, 2954, 2955, 2956, 2957, 2958, 2959, 2960, 2961, 2962, 2963, 2964, 2965, 2966, 2967, 2968, 2969, 2970, 2971, 2972, 2973, 2974, 2975, 2976, 2977, 2978, 2979, 2980, 2981, 2982, 2983, 2984, 2985, 2986, 2987, 2988, 2989, 2990, 2991, 2992, 2993, 2994, 2995, 2996, 2997, 2998, 2999, 3000, 3001, 3002, 3003, 3004, 3005, 3006, 3007, 3008, 3009, 3010, 3011, 3012, 3013, 3014, 3015, 3016, 3017, 3018, 3019, 3020, 3021, 3022, 3023, 3024, 3025, 3026, 3027, 3028, 3029, 3030, 3031, 3032, 3033, 3034, 3035, 3036, 3037, 3038, 3039, 3040, 3041, 3042, 3043, 3044, 3045, 3046, 3047, 3048, 3049, 3050, 3051, 3052, 3053, 3054, 3055, 3056, 3057, 3058, 3059, 3060, 3061, 3062, 3063, 3064, 3065, 3066, 3067, 3068, 3069, 3070, 3071, 3072, 3073, 3074, 3075, 3076, 3077, 3078, 3079, 3080, 3081, 3082, 3083, 3084, 3085, 3086, 3087, 3088, 3089, 3090, 3091, 3092, 3093, 3094, 3095, 3096, 3097, 3098, 3099, 3100, 3101, 3102, 3103, 3104, 3105, 3106, 3107, 3108, 3109, 3110, 3111, 3112, 3113, 3114, 3115, 3116, 3117, 3118, 3119, 3120, 3121, 3122, 3123, 3124, 3125, 3126, 3127, 3128, 3129, 3130, 3131, 3132, 3133, 3134, 3135, 3136, 3137, 3138, 3139, 3140, 3141, 3142, 3143, 3144, 3145, 3146, 3147, 3148, 3149, 3150, 3151, 3152, 3153, 3154, 3155, 3156, 3157, 3158, 3159, 3160, 3161, 3162, 3163, 3164, 3165, 3166, 3167, 3168, 3169, 3170, 3171, 3172, 3173, 3174, 3175, 3176, 3177, 3178, 3179, 3180, 3181, 3182, 3183, 3184, 3185, 3186, 3187, 3188, 3189, 3190, 3191, 3192, 3193, 3194, 3195, 3196, 3197, 3198, 3199, 3200, 3201, 3202, 3203, 3204, 3205, 3206, 3207, 3208, 3209, 3210, 3211, 3212, 3213, 3214, 3215, 3216, 3217, 3218, 3219, 3220, 3221, 3222, 3223, 3224, 3225, 3226, 3227, 3228, 3229, 3230, 3231, 3232, 3233, 3234, 3235, 3236, 3237, 3238, 3239, 3240, 3241, 3242, 3243, 3244, 3245, 3246, 3247, 3248, 3249, 3250, 3251, 3252, 3253, 3254, 3255, 3256, 3257, 3258, 3259, 3260, 3261, 3262, 3263, 3264, 3265, 3266, 3267, 3268, 3269, 3270, 3271, 3272, 3273, 3274, 3275, 3276, 3277, 3278, 3279, 3280, 3281, 3282, 3283, 3284, 3285, 3286, 3287, 3288, 3289, 3290, 3291, 3292, 3293, 3294, 3295, 3296, 3297, 3298, 3299, 3300, 3301, 3302, 3303, 3304, 3305, 3306, 3307, 3308, 3309, 3310, 3311, 3312, 3313, 3314, 3315, 3316, 3317, 3318, 3319, 3320, 3321, 3322, 3323, 3324, 3325, 3326, 3327, 3328, 3329, 3330, 3331, 3332, 3333, 3334, 3335, 3336, 3337, 3338, 3339, 3340, 3341, 3342, 3343, 3344, 3345, 3346, 3347, 3348, 3349, 3350, 3351, 3352, 3353, 3354, 3355, 3356, 3357, 3358, 3359, 3360, 3361, 3362, 3363, 3364, 3365, 3366, 3367, 3368, 3369, 3370, 3371, 3372, 3373, 3374, 3375, 3376, 3377, 3378, 3379, 3380, 3381, 3382, 3383, 3384, 3385, 3386, 3387, 3388, 3389, 3390, 3391, 3392, 3393, 3394, 3395, 3396, 3397, 3398, 3399, 3400, 3401, 3402, 3403, 3404, 3405, 3406, 3407, 3408, 3409, 3410, 3411, 3412, 3413, 3414, 3415, 3416, 3417, 3418, 3419, 3420, 3421, 3422, 3423, 3424, 3425, 3426, 3427, 3428, 3429, 3430, 3431, 3432, 3433, 3434, 3435, 3436, 3437, 3440, 3456, 3495, 3501, 3525, 3540, 3550, 3556, 3561, 3577, 3592, 3609, 3633, 3651, 3674, 3677, 3684, 3692, 3721, 3741, 3750, 3756, 3797, 3830, 3851, 3872, 3877, 3886, 3943, 3948, 3962]]
In [93]:
plt_network(graph_107)
In [94]:
plot_community_subgraph(subgraph_107, community_node_groups_107)
Graph_107 Greedy modularity
In [95]:
greed_community_107 = greedy_modularity_communities(subgraph_107)
greed_list_107 = list(greed_community_107)
print("number of communities is", len(list(greed_community_107)))
print(greed_list_107)
number of communities is 11
[frozenset({107, 348, 349, 350, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 394, 395, 396, 397, 398, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 455, 456, 457, 458, 459, 460, 461, 462, 463, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 579, 580, 581, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 596, 597, 598, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 629, 630, 631, 633, 634, 636, 637, 638, 639, 641, 642, 644, 645, 646, 648, 649, 651, 652, 653, 654, 655, 656, 657, 660, 663, 664, 666, 667, 668, 669, 671, 672, 673, 674, 676, 677, 678, 679, 680, 682, 683, 684, 685, 896, 898, 902, 904, 905, 907, 910, 911, 912, 913, 914, 915, 917, 918, 919, 924, 930, 931, 933, 935, 936, 937, 939, 940, 941, 942, 943, 944, 945, 948, 949, 954, 957, 962, 964, 965, 968, 969, 971, 974, 975, 976, 977, 981, 984, 985, 986, 987, 988, 989, 994, 1000, 1001, 1002, 1005, 1007, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1018, 1019, 1020, 1021, 1022, 1025, 1027, 1032, 1035, 1036, 1037, 1041, 1042, 1044, 1046, 1051, 1052, 1053, 1057, 1060, 1062, 1064, 1065, 1066, 1067, 1070, 1071, 1072, 1080, 1081, 1082, 1089, 1090, 1093, 1094, 1095, 1096, 1099, 1100, 1102, 1103, 1104, 1105, 1106, 1108, 1109, 1113, 1114, 1115, 1119, 1120, 1121, 1122, 1127, 1129, 1131, 1134, 1139, 1141, 1142, 1143, 1145, 1147, 1148, 1152, 1154, 1155, 1158, 1159, 1162, 1166, 1167, 1168, 1169, 1170, 1176, 1179, 1183, 1188, 1189, 1190, 1192, 1194, 1200, 1202, 1203, 1204, 1206, 1208, 1210, 1212, 1213, 1215, 1217, 1221, 1223, 1224, 1225, 1226, 1227, 1228, 1229, 1231, 1233, 1234, 1235, 1236, 1237, 1240, 1241, 1244, 1245, 1246, 1247, 1248, 1249, 1253, 1257, 1258, 1259, 1260, 1261, 1262, 1263, 1264, 1268, 1270, 1273, 1275, 1276, 1277, 1279, 1281, 1282, 1284, 1286, 1292, 1294, 1295, 1296, 1298, 1299, 1300, 1303, 1304, 1306, 1308, 1309, 1310, 1311, 1313, 1315, 1316, 1318, 1320, 1322, 1324, 1326, 1332, 1334, 1338, 1342, 1343, 1345, 1347, 1348, 1349, 1350, 1353, 1354, 1355, 1356, 1357, 1358, 1362, 1364, 1366, 1372, 1373, 1374, 1379, 1381, 1382, 1385, 1386, 1392, 1394, 1396, 1397, 1400, 1404, 1406, 1408, 1412, 1413, 1414, 1415, 1417, 1418, 1422, 1423, 1425, 1426, 1427, 1428, 1429, 1430, 1432, 1435, 1436, 1438, 1443, 1444, 1446, 1448, 1451, 1453, 1454, 1455, 1459, 1462, 1464, 1466, 1469, 1472, 1473, 1474, 1475, 1478, 1479, 1481, 1482, 1487, 1489, 1490, 1492, 1495, 1496, 1497, 1500, 1502, 1503, 1504, 1506, 1507, 1508, 1510, 1512, 1514, 1515, 1525, 1526, 1529, 1531, 1536, 1540, 1541, 1543, 1545, 1549, 1550, 1560, 1565, 1566, 1569, 1573, 1574, 1575, 1576, 1578, 1581, 1582, 1583, 1586, 1587, 1591, 1592, 1595, 1596, 1599, 1602, 1606, 1607, 1611, 1616, 1624, 1625, 1627, 1628, 1630, 1631, 1633, 1634, 1635, 1636, 1638, 1640, 1645, 1646, 1647, 1649, 1650, 1654, 1655, 1657, 1658, 1660, 1661, 1664, 1667, 1671, 1672, 1673, 1677, 1679, 1680, 1681, 1682, 1686, 1690, 1691, 1692, 1693, 1694, 1695, 1696, 1699, 1703, 1704, 1706, 1709, 1711, 1713, 1715, 1716, 1720, 1725, 1727, 1728, 1729, 1731, 1732, 1738, 1739, 1740, 1742, 1743, 1744, 1745, 1748, 1749, 1751, 1755, 1756, 1759, 1760, 1762, 1763, 1764, 1766, 1767, 1770, 1773, 1776, 1777, 1778, 1781, 1783, 1785, 1786, 1790, 1794, 1801, 1807, 1808, 1812, 1814, 1815, 1818, 1820, 1824, 1828, 1829, 1830, 1831, 1834, 1840, 1841, 1844, 1847, 1848, 1850, 1853, 1855, 1857, 1859, 1862, 1869, 1870, 1871, 1872, 1873, 1875, 1876, 1878, 1881, 1882, 1884, 1885, 1887, 1890, 1893, 1894, 1896, 1897, 1899, 1901, 1903, 1904, 1906, 1907, 1910}), frozenset({1321, 3366, 2661, 2662, 2665, 2667, 2668, 2671, 2672, 2674, 2675, 2677, 2678, 2682, 2684, 2685, 2686, 2687, 2688, 2690, 2691, 2692, 2693, 2696, 2697, 2700, 2701, 2702, 2707, 2708, 2709, 2711, 2712, 2713, 2714, 2715, 2716, 2718, 2719, 2720, 2721, 2722, 2723, 2724, 2725, 2727, 2728, 2730, 2732, 2733, 2734, 2735, 2736, 2737, 2739, 2742, 2744, 2747, 2748, 2751, 2752, 2753, 2758, 2759, 2760, 2762, 2764, 2765, 2768, 2770, 2771, 2772, 2775, 2776, 2778, 2779, 2780, 2781, 2783, 2784, 2785, 2787, 2788, 2790, 2791, 2792, 2793, 2795, 2796, 2797, 2799, 2801, 2802, 2803, 2804, 2805, 2808, 2811, 2812, 2813, 2816, 2818, 2819, 2820, 2822, 2823, 2824, 2825, 2826, 2828, 2829, 2830, 2831, 2832, 2833, 2836, 2840, 2841, 2842, 2843, 2844, 2845, 2846, 2847, 2848, 2849, 2853, 2855, 2856, 2857, 2858, 2859, 2860, 2861, 2863, 2865, 2868, 2869, 2870, 2871, 2875, 2876, 2878, 2881, 2882, 2883, 2886, 2892, 2893, 2894, 2895, 2898, 2900, 2901, 2902, 2903, 2904, 860, 2914, 2918, 2921, 2922, 2923, 2926, 2930, 2932, 2933, 2934, 2935, 2936, 2937, 2938, 2939, 2941, 2942, 2946, 2947, 900, 2949, 2950, 2951, 2952, 2954, 2955, 908, 2957, 2958, 909, 2961, 2962, 2964, 2965, 920, 2968, 2970, 922, 923, 2973, 2971, 2975, 928, 929, 2976, 2979, 2980, 2983, 2984, 2989, 2990, 2991, 2992, 2995, 2996, 2997, 2998, 950, 951, 3001, 3002, 955, 2999, 3005, 3006, 3007, 3009, 961, 3011, 3012, 3013, 3015, 3016, 3017, 3018, 970, 3019, 3021, 973, 3020, 3024, 3027, 3028, 3031, 3032, 3034, 3035, 3037, 3038, 3039, 990, 3041, 991, 3043, 996, 3046, 3048, 3049, 3050, 3051, 3053, 1008, 3057, 3058, 3060, 3061, 3062, 3063, 3066, 3067, 3068, 3069, 3070, 3071, 3072, 1023, 3075, 3076, 3077, 1030, 1031, 3079, 3081, 3082, 3083, 1033, 1034, 3086, 3087, 3088, 3089, 1038, 3091, 1043, 3093, 3094, 1045, 3097, 1050, 3099, 3100, 3101, 3102, 3103, 1055, 3105, 3106, 3107, 1058, 3109, 3110, 1061, 3112, 3113, 3111, 3115, 3116, 3117, 3118, 3120, 3121, 3122, 1073, 3124, 3125, 3126, 1077, 3128, 3131, 3132, 3133, 3134, 1085, 1087, 1088, 3138, 3136, 3140, 3141, 3144, 3145, 3146, 1098, 3148, 3150, 3151, 3152, 3154, 3155, 3156, 3157, 3159, 3160, 3161, 1111, 3162, 3164, 3165, 3167, 3168, 3169, 3170, 3171, 3172, 3173, 3175, 3176, 3177, 3178, 3179, 3180, 3181, 3182, 3183, 1136, 3185, 3186, 3187, 3188, 3189, 3190, 3191, 3192, 1140, 3194, 1144, 3196, 3197, 3198, 3199, 3200, 1150, 3201, 3203, 3204, 1157, 3206, 3207, 3208, 3209, 3210, 3211, 3212, 1161, 3214, 3215, 3216, 3217, 3218, 3219, 1165, 3221, 1171, 3223, 3224, 3225, 1174, 3227, 1178, 3222, 3230, 3233, 3235, 3236, 1187, 3239, 3240, 3241, 3242, 1193, 3244, 1197, 3246, 3247, 3245, 3249, 3248, 3251, 3252, 3253, 3254, 3255, 3256, 3258, 3259, 3260, 3261, 3262, 3263, 3264, 3265, 3266, 3267, 3268, 3270, 3271, 3272, 3273, 3274, 3275, 3276, 3277, 3278, 3279, 3280, 3281, 3282, 3285, 3287, 3288, 3289, 3291, 3292, 3295, 3296, 3297, 3298, 3299, 1251, 1252, 3302, 1254, 3304, 3305, 3306, 3307, 3308, 3310, 3312, 3313, 1266, 3316, 3319, 3320, 3321, 3322, 3323, 1274, 3326, 3327, 3328, 3329, 3330, 1283, 3332, 3331, 3334, 3335, 3336, 3337, 3338, 3340, 3341, 3342, 3343, 3344, 3345, 3346, 3347, 1297, 3349, 3350, 3351, 3352, 3353, 3354, 1301, 3356, 3357, 3358, 3359, 3360, 1307, 3361, 3355, 3365, 1317, 3367, 3368, 3369, 3370, 3371, 3372, 3373, 3374, 3375, 3376, 3377, 3378, 3379, 3380, 3381, 1325, 3383, 1327, 1328, 1337, 3386, 3385, 3389, 3391, 3393, 3395, 3396, 3397, 3398, 3401, 3402, 3403, 3404, 3405, 3406, 3407, 3408, 1360, 3410, 3411, 3412, 3409, 3415, 3416, 1368, 3418, 3419, 1369, 3421, 3422, 3420, 3424, 3425, 3427, 3429, 3431, 3432, 1383, 3434, 1384, 1387, 1395, 1405, 1410, 1419, 1421, 1433, 1434, 1440, 1441, 1445, 1450, 1461, 1476, 1477, 1486, 1494, 1505, 1511, 1518, 1521, 1527, 1534, 1537, 1544, 1552, 1553, 1555, 1558, 1561, 1564, 1567, 1579, 1585, 1588, 1593, 1594, 1615, 1626, 1641, 1642, 1656, 1666, 1670, 1674, 1676, 1678, 1684, 1687, 1697, 1698, 1701, 1702, 1705, 1708, 1719, 1726, 1758, 1779, 1780, 1788, 3205, 1792, 1803, 1805, 1806, 1817, 1822, 1825, 1838, 1846, 1852, 1858, 1860, 1863, 1865, 1866, 1883, 1905, 1908, 1909, 1911}), frozenset({0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 351, 364, 393, 399, 427, 441, 454, 464, 476, 501, 549, 564, 2704, 2740, 2814, 2838, 2885, 3003, 3290}), frozenset({897, 899, 906, 916, 921, 925, 926, 927, 932, 934, 946, 947, 952, 953, 959, 960, 966, 967, 972, 978, 980, 982, 983, 993, 995, 997, 998, 999, 1003, 1004, 1006, 1017, 1024, 1026, 1028, 1029, 1039, 1040, 1047, 1048, 1049, 1054, 1056, 1059, 1063, 1068, 1069, 1074, 1075, 1076, 1078, 1079, 1083, 1084, 1086, 1091, 1092, 1101, 1107, 1110, 1112, 1116, 1117, 1123, 1124, 1125, 1126, 1128, 1130, 1132, 1133, 1135, 1146, 1149, 1151, 1153, 1156, 1160, 1163, 1164, 1172, 1173, 1175, 1180, 1181, 1182, 1184, 1185, 1191, 1195, 1196, 1198, 1199, 1201, 1205, 1207, 1209, 1211, 1214, 1219, 1220, 1222, 1230, 1238, 1239, 1242, 1243, 1250, 1255, 1256, 1265, 1267, 1269, 1271, 1272, 1278, 1280, 1285, 1287, 1288, 1289, 1290, 1291, 1293, 1302, 1305, 1312, 1323, 1329, 1330, 1331, 1335, 1336, 1339, 1340, 1341, 1344, 1346, 1351, 1352, 1359, 1361, 1365, 1367, 1370, 1375, 1376, 1377, 1380, 1388, 1389, 1390, 1391, 1393, 1398, 1399, 1401, 1402, 1407, 1409, 1411, 1416, 1420, 1431, 1437, 1439, 1442, 1447, 1449, 1456, 1457, 1458, 1460, 1463, 1467, 1470, 1471, 1480, 1483, 1484, 1485, 1488, 1491, 1498, 1501, 1509, 1513, 1516, 1517, 1519, 1520, 1522, 1523, 1524, 1528, 1530, 1532, 1535, 1538, 1539, 1542, 1547, 1551, 1554, 1556, 1557, 1559, 1563, 1570, 1571, 1572, 1580, 1584, 1589, 1590, 1597, 1598, 1600, 1603, 1604, 1605, 1608, 1609, 1610, 1612, 1613, 1614, 1617, 1618, 1619, 1620, 1621, 1622, 1623, 1632, 1637, 1639, 1643, 1644, 1651, 1652, 1653, 1659, 1662, 1663, 1665, 1668, 1669, 1675, 1683, 1685, 1688, 1689, 1700, 1707, 1710, 1712, 1714, 1717, 1721, 1722, 1723, 1724, 1730, 1734, 1735, 1736, 1737, 1741, 1746, 1750, 1752, 1753, 1754, 1757, 1761, 1765, 1768, 1769, 1771, 1772, 1774, 1775, 1782, 1789, 1791, 1793, 1795, 1796, 1797, 1799, 1800, 1804, 1809, 1810, 1811, 1813, 1816, 1819, 1821, 1823, 1826, 1827, 1832, 1833, 1835, 1836, 1839, 1842, 1843, 1845, 1849, 1851, 1854, 1856, 1861, 1864, 1867, 1868, 1874, 1877, 1879, 1886, 1888, 1891, 1898, 1900, 1902}), frozenset({3073, 3078, 3080, 3084, 3085, 3090, 3092, 3095, 3096, 3098, 3104, 3108, 3114, 3119, 3123, 3129, 3130, 3135, 3137, 3139, 3142, 3143, 3149, 3153, 3158, 3163, 3166, 3174, 2663, 2664, 2666, 2669, 3184, 2673, 2676, 2679, 2680, 3193, 2681, 3195, 2683, 2689, 3202, 2694, 2695, 2698, 3213, 2705, 2706, 3220, 2710, 3226, 3228, 3229, 2717, 3231, 3232, 3234, 3237, 3238, 2726, 2729, 2731, 3243, 2738, 3250, 2741, 2743, 2745, 2746, 3257, 2749, 2750, 2754, 2755, 2756, 2757, 3269, 2761, 2763, 2766, 2769, 3284, 2773, 3286, 2777, 3293, 2782, 3294, 2786, 3300, 3301, 2789, 3303, 2794, 2798, 2800, 3315, 3317, 2806, 2807, 2809, 2810, 3324, 2815, 3333, 2821, 3339, 2827, 2835, 3348, 2837, 2839, 3362, 3363, 3364, 2850, 2851, 2852, 2854, 2862, 2864, 2866, 2867, 3384, 2872, 2873, 3387, 3388, 2877, 3390, 2874, 2880, 3392, 3394, 2884, 3399, 3400, 2887, 2888, 2890, 2891, 2896, 2897, 2899, 3413, 3414, 3417, 2905, 2906, 2907, 2908, 2909, 2910, 2911, 2912, 3426, 2913, 3428, 2915, 3430, 2916, 2917, 3433, 2919, 3435, 3436, 2920, 2924, 2925, 2927, 2928, 2929, 2931, 2940, 2943, 2944, 2945, 2948, 2953, 2956, 2960, 2963, 2966, 2967, 2969, 2974, 2977, 2978, 2981, 2985, 2986, 2987, 2988, 2993, 2994, 3000, 3004, 3010, 3014, 3022, 3023, 3025, 3026, 3029, 3030, 3033, 3036, 3040, 3042, 3044, 3045, 3047, 3052, 3054, 3056, 3059, 3064, 3065}), frozenset({2052, 2053, 2054, 2567, 2062, 2065, 2068, 2582, 2071, 2072, 2588, 2589, 2592, 2081, 2594, 2597, 2598, 2087, 1577, 2605, 2608, 2609, 2101, 2102, 2616, 2617, 2111, 2117, 2629, 2125, 2127, 2128, 2642, 2643, 2132, 2133, 2134, 2135, 2137, 2649, 2138, 2653, 2143, 2144, 2148, 2149, 2151, 2153, 2155, 2163, 2169, 2174, 2176, 2180, 2183, 2185, 2187, 2189, 2191, 2194, 2196, 2198, 2199, 2203, 2215, 2223, 2224, 1718, 2239, 2241, 2246, 2247, 2250, 2254, 2264, 2266, 2267, 2268, 2273, 2279, 2282, 2283, 2285, 2289, 2292, 2293, 2294, 2295, 2298, 2302, 2315, 2319, 2325, 2327, 2328, 2330, 2332, 2333, 2336, 2338, 2343, 2344, 2347, 2351, 2355, 2368, 2372, 2377, 2384, 2385, 2389, 2394, 2398, 2399, 2413, 2417, 2419, 2420, 1912, 1913, 1916, 1920, 2436, 1926, 1932, 2445, 2451, 1940, 1941, 1945, 2458, 1947, 1948, 2461, 2463, 2465, 1954, 1955, 2468, 1959, 2471, 2472, 2475, 1967, 1465, 2491, 2496, 2498, 2501, 2502, 1994, 2508, 2509, 2510, 2511, 2512, 2002, 2003, 2516, 2007, 2519, 2010, 2529, 2530, 2533, 2026, 2028, 2542, 2031, 2544, 2543, 2032, 2547, 2038, 2039, 2042, 2555, 2047}), frozenset({901, 1798, 903, 1802, 1546, 1548, 1424, 1403, 1177, 1562, 1568, 1186, 1314, 1319, 938, 1452, 1837, 1333, 956, 1468, 958, 1216, 1601, 1218, 963, 1733, 1097, 1232, 1747, 1363, 979, 1493, 1880, 1016, 1371, 1499, 1629, 1118, 992, 1889, 1378, 1892, 1895, 1648, 1137, 1138, 1784, 1787, 1533}), frozenset({3456, 3592, 3721, 3851, 3609, 3741, 3872, 3877, 3750, 3495, 3756, 3501, 3886, 3633, 3651, 3525, 3540, 3797, 3674, 3677, 3550, 862, 3684, 3556, 3943, 3561, 3948, 3692, 3437, 3440, 3830, 3577, 3962}), frozenset({640, 643, 647, 650, 658, 659, 661, 662, 665, 670, 675, 681, 576, 577, 578, 582, 583, 595, 599, 600, 615, 627, 628, 632, 635}), frozenset({2699, 2959, 2703, 2834, 2972, 2982, 3382, 2879, 3008, 2889, 2767, 3283, 3423, 3309, 2670, 3311, 3314, 3318, 3325}), frozenset({2817, 3074, 3147, 3055, 2774, 3127})]
In [96]:
print("Modularity:", nx.algorithms.community.modularity(subgraph_107, greed_list_107))
Modularity: 0.7670019886779921
In [97]:
plot_community_subgraph(subgraph_107, greed_list_107)
In [104]:
####Let's define the neighbourhood
def CommonNeighbors(u, v, g):
    u_neighbors = set(g.neighbors(u))
    v_neighbors = set(g.neighbors(v))
    return len(u_neighbors.intersection(v_neighbors))
def common_neighbors(g, edges):
    list_neighbours = []
    for edge in edges:
        node_one, node_two = edge[0], edge[1]
        num_common_neighbors = 0
        try:
            neighbors_one, neighbors_two = g.neighbors(node_one), g.neighbors(node_two)
            for neighbor in neighbors_one:
                if neighbor in neighbors_two:
                    num_common_neighbors += 1
            list_neighbours.append((node_one, node_two, num_common_neighbors))
        except:
            pass
    return list_neighbours
In [105]:
####Let's define the feature set
feature_set = [common_neighbors,
                   nx.resource_allocation_index,
                   nx.jaccard_coefficient,
                   nx.adamic_adar_index,
                   nx.preferential_attachment
                   ]
In [106]:
#### Let's create the fakeedges for negative sample
def produce_fake_edge(g, neg_g,num_test_edges):
    i = 0
    while i < num_test_edges:
        edge = random.sample(g.nodes(), 2)
        try:
            shortest_path = nx.shortest_path_length(g,source=edge[0],target=edge[1])
            if shortest_path >= 2:
                neg_g.add_edge(edge[0],edge[1], positive="False")
                i += 1
        except:
            pass
In [107]:
def sample_extraction(g, pos_num, neg_num):
    # randomly select pos_num as test edges
    print("----------------extract positive samples--------------------")
    pos_sample = random.sample(g.edges(), pos_num)
 
    # adding non-existing edges
    print("----------------extract negative samples--------------------")
    neg_g = nx.Graph()
    produce_fake_edge(g,neg_g,neg_num)
    neg_sample = neg_g.edges()
    
    # remove the positive sample edges, the rest is the training set
    g.remove_edges_from(pos_sample)
    
    return pos_sample, neg_sample
In [108]:
def feature_extraction(g, pos_sample, neg_sample, feature_name, model="single", combine_num=2):

    data = []
    label = ["label"] + ["1" for i in range(len(pos_sample))] + ["0" for i in range(len(neg_sample))]
    for j in feature_name:
        print ("-----extract feature:", j.__name__, "----------")
        preds = j(g, pos_sample)

        feature = [j.__name__] + [i[2] for i in preds]
        preds = j(g, neg_sample)
        feature = feature + [i[2] for i in preds]
        data.append(feature)

    data.append(label)
    data = transpose(data)
    print("----------write the features to file---------------")
    write_data_to_file(data, "features_" + model + "_" + str(combine_num) + ".csv")
    
    return data

def write_data_to_file(data, filename):
    csvfile = open(filename, "w")
    writer = csv.writer(csvfile)
    for i in data:
        writer.writerow(i)
    csvfile.close()


def transpose(data):
    return [list(i) for i in zip(*data)]
In [109]:
def link_predict(filename="facebook_combined.txt", pos_num=0.5, neg_num=0.5, model="combined", combine_num=1,
         feature_name=common_neighbors):
    g = nx.read_edgelist(filename, create_using = nx.Graph(), nodetype=int)
    num_edges = g.number_of_edges()
    pos_num = int(num_edges * pos_num)
    neg_num = int(num_edges * neg_num)
    pos_sample, neg_sample = sample_extraction(g, pos_num, neg_num)
    train_data = feature_extraction(g, pos_sample, neg_sample, feature_name, model, combine_num)
In [110]:
link_predict(filename="facebook_combined.txt",model="combined",combine_num=2, feature_name=feature_set)
----------------extract positive samples--------------------
----------------extract negative samples--------------------
-----extract feature: common_neighbors ----------
-----extract feature: resource_allocation_index ----------
-----extract feature: jaccard_coefficient ----------
-----extract feature: adamic_adar_index ----------
-----extract feature: preferential_attachment ----------
----------write the features to file---------------
In [111]:
data_array = np.loadtxt(open("features_combined_2.csv", "rb"), delimiter=",", skiprows=1)
a,b=data_array.shape;
np.random.shuffle(data_array);
In [112]:
train_l=int(0.8*a)
X_train=data_array[0:train_l,0:b-1]
Y_train=data_array[0:train_l,b-1]
X_test=data_array[train_l:a,0:b-1]
Y_test=data_array[train_l:a,b-1]
X_train = normalize(X_train, axis=0, norm='max')
X_test = normalize(X_test, axis=0, norm='max')
scaler = StandardScaler()  
scaler.fit(X_train)  
X_train = scaler.transform(X_train)  
X_test = scaler.transform(X_test)
SVM Model
In [113]:
def svm_model(training, training_labels, testing, testing_labels):
    #Support Vector Machine
    clf = svm.SVC()
    clf.fit(training, training_labels)
    result = clf.predict(testing)
    
    print("SVM accuracy:", accuracy_score(testing_labels, result))
    print("SVM F1 Score:", f1_score(result, testing_labels,average='macro'))
In [114]:
svm_model(X_train,Y_train,X_test,Y_test)
SVM accuracy: 0.9572198581560284
SVM F1 Score: 0.9572196035178815
Logistic regression model
In [115]:
def logistic_model(training, training_labels, testing, testing_labels):
    clf = LogisticRegression(random_state=0, solver='lbfgs',multi_class='ovr').fit(training, training_labels)
    clf.fit(training, training_labels)
    result=clf.predict(testing)
    
    print ("Logistic regression accuracy:", accuracy_score(testing_labels, result)) 
    print("Logistic regression F1 Score:", f1_score(result, testing_labels,average='macro'))
In [116]:
logistic_model(X_train,Y_train,X_test,Y_test)
Logistic regression accuracy: 0.9553475177304964
Logistic regression F1 Score: 0.9553421071553178